我正在使用Vue2Leaflet(https://github.com/KoRiGaN/Vue2Leaflet)和vuejs2,我已经渲染了地图,并且我想添加一个函数来处理单击地图时的问题,因为我正在阅读文档https://korigan.github.io/Vue2Leaflet/#/,但仍然不知道该怎么做。
任何建议都将不胜感激。
发布于 2018-12-28 06:25:19
下面的示例演示了如何在Vue2Leaflet中处理映射单击事件
<l-map :zoom="zoom" :center="center" @click="handleMapClick">
<l-tile-layer :url="url" :attribution="attribution"></l-tile-layer>
</l-map>
export default {
name: "LeafletMap",
components: {
"l-map": LMap,
"l-tile-layer": LTileLayer,
"l-marker": LMarker
},
data() {
return {
zoom: 13,
center: L.latLng(47.41322, -1.219482),
url: "http://{s}.tile.osm.org/{z}/{x}/{y}.png",
attribution:
'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
};
},
methods: {
handleMapClick(event) {
//...
}
}
};这是a demo
https://stackoverflow.com/questions/53930771
复制相似问题