smoothing large polygons

737 views
Skip to first unread message

hvr

unread,
Nov 16, 2009, 5:19:14 PM11/16/09
to Google Maps JavaScript API v3
Hi There,

I'm responsible for a project where we are mapping polygons on a
google map. my dilemma is that the data points i've been given are
really really accurate. Some polygons are larger than 75,000 points.
Using V3 of the API what are my options for smoothing these polygons?

I notice that V2 of the API has an encoding function which will do
this but no such feature exists for V3. I've also investigated using
3rd party libraries but these all seem to be written for V2.

Ben Appleton

unread,
Nov 16, 2009, 9:49:42 PM11/16/09
to google-map...@googlegroups.com
Hi,

v3 will smooth your polygons in the browser, but it is much faster to smooth your polygons offline.  There are GIS packages that will do this for you, or you could try writing your own.  See for example http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.

- Ben


--

You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=.



arclyte

unread,
Nov 17, 2009, 4:04:05 PM11/17/09
to Google Maps JavaScript API v3
For encoding, check out:

http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/

There's code there for a few different languages.

I think you'd definitely want to simplify the polygons prior to even
using them in production.

hvr

unread,
Nov 17, 2009, 5:22:28 PM11/17/09
to Google Maps JavaScript API v3
Thanks for the link. Do the encoding examples you've linked to work
with V3 of the API?

arclyte

unread,
Nov 17, 2009, 5:47:33 PM11/17/09
to Google Maps JavaScript API v3
There's no functionality similar to v2's fromEncoded in v3 yet. While
the encoding does do polyline simplification for loading, I'd suggest
you adapt a similar technique (ala the Ramer-Douglas-Peucker
algorithm) to your current dataset. It'd be better for your servers
and your users if you're not throwing 75k points at the maps api.
While I get the idea of the technique, I won't pretend to fully
understand all of the math behind it. I didn't pay that much attention
in geometry class unfortunately. But I think there's enough code
samples out there to get you where you need to go...
Reply all
Reply to author
Forward
0 new messages