UNPKG

@vuemap/vue-amap

Version:

高德地图vue3版本封装

58 lines (55 loc) 1.79 kB
import { defineComponent, provide, openBlock, createElementBlock, renderSlot } from 'vue'; import '../../../../mixins/index.mjs'; import { buildProps } from '../../../../utils/buildHelper.mjs'; import { provideKey, useRegister } from '../../../../mixins/useRegister.mjs'; var script = /* @__PURE__ */ defineComponent({ ...{ name: "ElAmapLayerVector", inheritAttrs: false }, __name: "Vector", props: buildProps({}), emits: ["init"], setup(__props, { expose: __expose, emit: __emit }) { const needInitComponents = []; const provideData = { $amapComponent: void 0, addChildComponent(cb) { needInitComponents.push(cb); }, isDestroy: false }; provide(provideKey, provideData); const emits = __emit; let $amapComponent; const { $$getInstance, parentInstance } = 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 openBlock(), createElementBlock("div", null, [ renderSlot(_ctx.$slots, "default") ]); }; } }); export { script as default }; //# sourceMappingURL=Vector.vue2.mjs.map