码迷,mamicode.com
首页 > 其他好文 > 详细

leaflet esri 添加label

时间:2020-07-13 09:15:34      阅读:49      评论:0      收藏:0      [点我收藏+]

标签:class   marker   fun   add   layer   label   enter   添加   cti   

var labels = {};

earthquakes.on(‘createfeature‘, function (e) {
var id = e.feature.id;
var feature = earthquakes.getFeature(id);
var center = feature.getLatLng();
var label = L.marker(center, {
icon: L.divIcon({
iconSize: null,
className: ‘label‘,
html: ‘<div>‘ + e.feature.properties.name + ‘</div>‘
})
}).addTo(map);
labels[id] = label;
});

earthquakes.on(‘addfeature‘, function (e) {
var label = labels[e.feature.id];
if (label) {
label.addTo(map);
}
});

earthquakes.on(‘removefeature‘, function (e) {
var label = labels[e.feature.id];
if (label) {
map.removeLayer(label);
}
});

leaflet esri 添加label

标签:class   marker   fun   add   layer   label   enter   添加   cti   

原文地址:https://www.cnblogs.com/googlegis/p/13291428.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!