1 Star 0 Fork 0

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
example.vue 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
Julian Perelli 提交于 2019-10-31 19:58 . Improve example and bump versions
<template>
<v-map :zoom=10 :center="initialLocation">
<v-icondefault></v-icondefault>
<v-tilelayer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"></v-tilelayer>
<v-marker-cluster :options="clusterOptions" @clusterclick="click()" @ready="ready">
<v-marker v-for="l in locations" :key="l.id" :lat-lng="l.latlng" :icon="icon">
<v-popup :content="l.text"></v-popup>
</v-marker>
</v-marker-cluster>
</v-map>
</template>
<script>
import * as Vue2Leaflet from 'vue2-leaflet'
import { latLng, Icon, icon } from 'leaflet'
import Vue2LeafletMarkercluster from './Vue2LeafletMarkercluster'
import iconUrl from 'leaflet/dist/images/marker-icon.png'
import shadowUrl from 'leaflet/dist/images/marker-shadow.png'
function rand(n) {
let max = n + 0.1
let min = n - 0.1
return Math.random() * (max - min) + min;
}
export default {
components: {
'v-map': Vue2Leaflet.LMap,
'v-tilelayer': Vue2Leaflet.LTileLayer,
'v-icondefault': Vue2Leaflet.LIconDefault,
'v-marker': Vue2Leaflet.LMarker,
'v-popup': Vue2Leaflet.LPopup,
'v-marker-cluster': Vue2LeafletMarkercluster
},
methods: {
click: (e) => console.log("clusterclick", e),
ready: (e) => console.log('ready', e),
},
data () {
let locations = []
for (let i = 0; i < 100; i++) {
locations.push({
id: i,
latlng: latLng(rand(-34.9205), rand(-57.953646)),
text: 'Hola ' + i
})
}
let customicon = icon(Object.assign({},
Icon.Default.prototype.options,
{iconUrl, shadowUrl}
))
return {
locations,
icon: customicon,
clusterOptions: {},
initialLocation: latLng(-34.9205, -57.953646)
}
},
mounted() {
setTimeout(() => {
console.log('done')
this.$nextTick(() =>{
this.clusterOptions = { disableClusteringAtZoom: 11 }
});
}, 5000);
}
}
</script>
<style>
@import "~leaflet/dist/leaflet.css";
@import "~leaflet.markercluster/dist/MarkerCluster.css";
@import "~leaflet.markercluster/dist/MarkerCluster.Default.css";
html, body {
height: 100%;
margin: 0;
}
</style>
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

搜索帮助