@vuemap/vue-amap
Version:
高德地图vue3版本封装
130 lines (125 loc) • 3.13 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../mixins/index.js');
require('../../../utils/index.js');
var buildHelper = require('../../../utils/buildHelper.js');
var useRegister = require('../../../mixins/useRegister.js');
var script = /* @__PURE__ */ vue.defineComponent({
...{
name: "ElAmapCircleMarker",
inheritAttrs: false
},
__name: "CircleMarker",
props: buildHelper.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.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 vue.openBlock(), vue.createElementBlock("div");
};
}
});
exports.default = script;
//# sourceMappingURL=CircleMarker.vue2.js.map