Jul 042013
 

I found a script to simplify polygons in Google Maps, basically to reduce the number of nodes the polygon is build up from. It does that by some sort of smoothing algorithm, with a distance parameter. Anything under that distance is smoothed out (read: deleted). It’s a Google Maps V2 script, but I modified it to work with V3.

This is the original: Stack-based Douglas Peucker line simplification routine by Dr. Gary J. Robinson. Let me know if you need the V3 script, but it shouldn’t be a problem to do the modifications yourself.

When I set the tolerance (kink as it’s called in the script) to 10 (meter), my polygons have a node drop from almost 600 to about 30, and still look about the same as what was drawn. I can still optimize the query a little to only use 7 decimal digits on the lats/longs, but for now that’s not needed.

Come to think of it, the amount of smoothing should be linked to the zoomlevel the map is at when drawing the polygon.

Update 18-Aug-2016: The V3 file is this one.

  9 Responses to “Free form drawing on Google Maps – simplifying polygons”

  1. I would love to get the v3 script if possible. Working on a mobile app for real estate. Much appreciated.

  2. Just writing to say thank you very much! I needed something like this to simplify my polygons. You saved me lots of time and headaches!

  3. HI, is it possible to still request the v3 script?

Leave a Reply to Steven Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)