I have a difficult situation, I'm trying to draw a polygon through markers (points), what I need is for the polygon to be drawn automatically after tracing the points.

The problem is that most of the polygons will be irregular, because the points indicate a route through the roads, and the polygon has to draw around those points with 100 meters margin on both sides, and manage to capture the positions Of the bookmarks in a table using javascript.

I put an image referring to what I want to do, the dotted blue line shows the polygon, and the black circles are the points.

Example polygon

I am using javascript and google maps api, I would like to know if what I want to do is possible without using a lot of mathematics and I would need to do it, sorry my English since I do not master it, my language is Spanish.


1 Answer 1


if I've understood you correctly, what you want is called a buffer.

This can be easily achieved with a library called turfjs. It is easy to integrate this with an alternative to google maps called Leaflet.

Here is an example I've made of adding points to a leaflet map, connecting them with a polyline and buffering that polyline.

If you provide more details about how your data is stored I can be more specific about how you can get it onto the map.

  • This is great example, but I see that this forms with polylines, this way it is possible to calculate areas and objects that are inside the polygon?
    – Kelebra93
    Jun 23, 2017 at 18:35
  • Bigger polygon, now with area as a popup: Link. Turf has within functions too.
    – RoperMaps
    Jun 25, 2017 at 19:13

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.