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             })

 

相关文章:

  • 2021-06-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-07-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-02-07
  • 2022-12-23
相关资源
相似解决方案