1

Is there a way to draw lines and polygons (with geojson) and calculate distance and polygon surface with the mapbox api or leaflet? I wish to have the same tools as in geojson.io with the extra ability to calculate line length and polygon surface. For lines I will use the Leaflet method distanceTo but for the polygon surface I have no clue.

3
  • You'll need to be more detailed about what you're trying to accomplish, espec. re. "calculate ... polygon surface".
    – Martin F
    May 15, 2014 at 4:04
  • You mean polygon area, as in, say square metres? And do you mean conventional, horizontal (planar) area, and not surface area (which depends on terrain/relief)?
    – Martin F
    May 15, 2014 at 22:20
  • Correct I mean planar area
    – Inclanfunk
    May 16, 2014 at 23:36

1 Answer 1

3

Lines and polygons can be drawn in Leaflet either by the user of the application with Leaflet Draw

Or programmatically, with geojson - or other leaflet or mapbox classes

For distances and length you might look into Leaflet GeometryUtil

And you can calculate the area of a polygon with geojson-area

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.