UNPKG

@vuemap/vue-amap

Version:

高德地图vue3版本封装

126 lines (123 loc) 3.07 kB
import { defineComponent, openBlock, createElementBlock } from 'vue'; import '../../../mixins/index.mjs'; import '../../../utils/index.mjs'; import { buildProps } from '../../../utils/buildHelper.mjs'; import { useRegister } from '../../../mixins/useRegister.mjs'; var script = /* @__PURE__ */ defineComponent({ ...{ name: "ElAmapCircleMarker", inheritAttrs: false }, __name: "CircleMarker", props: buildProps({ zIndex: { type: Number }, center: { type: Array, required: true }, bubble: { type: Boolean, default: false }, cursor: { type: String }, radius: { type: Number }, strokeColor: { type: String }, strokeOpacity: { type: Number }, strokeWeight: { type: Number }, fillColor: { type: String }, fillOpacity: { type: Number }, draggable: { type: Boolean, default: false }, extData: { type: Object } }), emits: ["init", "update:center"], setup(__props, { expose: __expose, emit: __emit }) { const emits = __emit; let $amapComponent; const { $$getInstance, parentInstance } = useRegister((options, parentComponent) => { return new Promise((resolve) => { $amapComponent = new AMap.CircleMarker(options); parentComponent.add($amapComponent); bindModelEvents(); resolve($amapComponent); }); }, { emits, watchRedirectFn: { __strokeColor(value) { $amapComponent.setOptions({ strokeColor: value }); }, __strokeOpacity(value) { $amapComponent.setOptions({ strokeOpacity: value }); }, __strokeWeight(value) { $amapComponent.setOptions({ strokeWeight: value }); }, __fillColor(value) { $amapComponent.setOptions({ fillColor: value }); }, __fillOpacity(value) { $amapComponent.setOptions({ fillOpacity: value }); } }, destroyComponent() { if ($amapComponent && (parentInstance == null ? void 0 : parentInstance.$amapComponent)) { if (!(parentInstance == null ? void 0 : parentInstance.isDestroy)) { parentInstance == null ? void 0 : parentInstance.$amapComponent.remove($amapComponent); } $amapComponent = null; } } }); const bindModelEvents = () => { $amapComponent.on("dragend", () => { emitPosition(); }); $amapComponent.on("touchend", () => { emitPosition(); }); }; const emitPosition = () => { const center = $amapComponent.getCenter(); emits("update:center", center.toArray()); }; __expose({ $$getInstance }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div"); }; } }); export { script as default }; //# sourceMappingURL=CircleMarker.vue2.mjs.map