leaflet 自定义 featurelayer的 popup

 1 let linepopup;
 2 
 3             LineLayer.on('mouseover', function (e) {
 4 
 5                 let loc = e.layer.feature.geometry.coordinates;
 6                 let tooltip = e.layer.feature.properties.lineGXLX + ' DN ' + e.layer.feature.properties.lineGJ + ' ' + e.layer.feature.properties.lineGC
 7 
 8 
 9                 let latlng = L.latLng(loc[0][1], loc[0][0]);
10                 let length = e.layer.feature.properties.Shape__Length;
11 
12                 linepopup = L.popup()
13                     .setLatLng(latlng)
14                     .setContent('<p>' + tooltip + '<br /> 长度: ' + length.toFixed(2) + ' m</p>')
15                     .openOn(map);
16 
17             });
18 
19             LineLayer.on('mouseout', function (e) {
20                 if (linepopup) {
21                     linepopup.remove();
22                 }
23             })

 

posted @ 2020-07-13 09:05  googlegis  阅读(895)  评论(0编辑  收藏  举报

坐标合肥,非典型GIS开发人员 GitHub