1 Star 0 Fork 0

Leaflet和GeoServer开源GIS套餐/vue2-leaflet-markercluster

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Vue2LeafletMarkercluster.vue 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
David 提交于 2019-06-26 22:29 . Remove trailing commas
<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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/leaflet-unofficial-plugins/vue2-leaflet-markercluster.git
git@gitee.com:leaflet-unofficial-plugins/vue2-leaflet-markercluster.git
leaflet-unofficial-plugins
vue2-leaflet-markercluster
vue2-leaflet-markercluster
master

搜索帮助