代码拉取完成,页面将自动刷新
<template>
<div style="display: none;">
<slot v-if="ready"></slot>
</div>
</template>
<script>
import { MarkerClusterGroup } from 'leaflet.markercluster'
import { findRealParent, propsBinder } from 'vue2-leaflet'
import { DomEvent } from 'leaflet'
const props = {
options: {
type: Object,
default() { return {}; },
},
};
export default {
props,
data() {
return {
ready: false,
};
},
mounted() {
this.mapObject = new MarkerClusterGroup(this.options);
DomEvent.on(this.mapObject, this.$listeners);
propsBinder(this, this.mapObject, props);
this.ready = true;
this.parentContainer = findRealParent(this.$parent);
this.parentContainer.addLayer(this);
this.$nextTick(() => {
this.$emit('ready', this.mapObject);
});
},
beforeDestroy() {
this.parentContainer.removeLayer(this);
},
methods: {
addLayer(layer, alreadyAdded) {
if (!alreadyAdded) {
this.mapObject.addLayer(layer.mapObject);
}
},
removeLayer(layer, alreadyRemoved) {
if (!alreadyRemoved) {
this.mapObject.removeLayer(layer.mapObject);
}
}
}
};
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。