leaflet 自定义 featurelayer的 popup

Posted googlegis

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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             })

 

以上是关于leaflet 自定义 featurelayer的 popup的主要内容,如果未能解决你的问题,请参考以下文章

Leaflet / LayersControl / 移动设备上的自定义按钮

esri-leaflet入门教程-自定义底图

leaflet.draw.js可以自定义工具吗,比如制作一个调色板之类的。

Leaflet.js 中未显示自定义 Mapbox 瓦片集

React-leaflet 自定义组件 - 未传递上下文?

使用自定义创建的 Mapbox 样式(来自 Mapbox Studio)和 Leaflet