How to calculate the distance of a polyline in Leaflet like geojson.io?

后端 未结 3 2139
天涯浪人
天涯浪人 2021-02-15 03:29

I am working on a map with Mapbox and Leaflet and I am supposed to let the user draw polygons and calculate and show the are of that polygon and I also need to let the user draw

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-15 03:49

    And also that's the solution of calculate the area of circle.

    else if (type === 'circle') {
         var area = 0;
         var radius = e.layer.getRadius();
         area = (Math.PI) * (radius * radius);
         e.layer.bindPopup((area / 1000000).toFixed(2) + ' km2');
         e.layer.openPopup();
    }
    

提交回复
热议问题