@vuemap/vue-amap
Version:
高德地图vue3版本封装
62 lines (57 loc) • 1.84 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../../mixins/index.js');
var buildHelper = require('../../../../utils/buildHelper.js');
var useRegister = require('../../../../mixins/useRegister.js');
var script = /* @__PURE__ */ vue.defineComponent({
...{
name: "ElAmapLayerVector",
inheritAttrs: false
},
__name: "Vector",
props: buildHelper.buildProps({}),
emits: ["init"],
setup(__props, { expose: __expose, emit: __emit }) {
const needInitComponents = [];
const provideData = {
$amapComponent: void 0,
addChildComponent(cb) {
needInitComponents.push(cb);
},
isDestroy: false
};
vue.provide(useRegister.provideKey, provideData);
const emits = __emit;
let $amapComponent;
const { $$getInstance, parentInstance } = useRegister.useRegister((options, parentComponent) => {
return new Promise((resolve) => {
$amapComponent = new AMap.VectorLayer(options);
parentComponent.add($amapComponent);
resolve($amapComponent);
});
}, {
emits,
needInitComponents,
provideData,
destroyComponent() {
if ($amapComponent && (parentInstance == null ? void 0 : parentInstance.$amapComponent)) {
if (!(parentInstance == null ? void 0 : parentInstance.isDestroy)) {
parentInstance == null ? void 0 : parentInstance.$amapComponent.removeLayer($amapComponent);
}
$amapComponent = null;
}
}
});
__expose({
$$getInstance
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", null, [
vue.renderSlot(_ctx.$slots, "default")
]);
};
}
});
exports.default = script;
//# sourceMappingURL=Vector.vue2.js.map