问题
I read this answer on how to calculate the area of a polygon and I am trying to achieve the same. However, I consistently get 0 (zero) for the area.
JS fiddle is here. The crux of my code is:
var map = L.map('map').setView([19.04469, 72.9258], 12).addLayer(osm);
var latlngs = [[19.04469, 72.9258], [19.07459, 72.9358], [19.08469, 72.4758]];
var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
console.log('area is: '+L.GeometryUtil.geodesi
I consistently get area is: 0
on the console.
回答1:
You should add .getLatLngs()
see this fiddle
L.GeometryUtil.geodesicArea(polygon.getLatLngs()));
来源:https://stackoverflow.com/questions/60827549/how-to-calculate-area-of-polygon-using-leaflet-draw-geometryutil