Google maps polygon optimization

I think MapShaper can do this online

Otherwise, implement some algorithm


Found this simple javascript by Bill Chadwick. Just feed in the LatLng to an array and pass in to the source arguments in a function here Douglas Peucker line simplification routine

it will output an array with less points for polygon.

 var ArrayforPolygontoUse= GDouglasPeucker(theArrayofLatLng,2000) 
 var polygon=new google.maps.Polygon({ 

    path:ArrayforPolygontoUse,
    geodesic:true,
    strokeColor:"#0000FF",
    strokeOpacity:0.8,
    strokeWeight:2,
    fillColor:"#0000FF",
    fillOpacity:0.4,
    editable:true
  });

theArrayofLatLng is an array of latlng that you collected using google maps api. The 2000 value is kink in metres. My assumption is, the higher the value, more points will be deleted as an output.

For real beginners: Make sure you declare the js file on your html page before using it. :)

<script type="text/javascript" src="js/GDouglasPeucker.js"></script>