Search code examples
google-maps-api-3kmllayergeopoints

Google Maps - How do I efficiently create a polygon with many points?


I need a polygon for every German state. I go all the GeoPoints in one JavaScript-file but the file is because of the amout of points about 4MB. I've been googling and thinking about this problem all day but couldn't figure out a solution...

How can I use Google Maps polygons without forcing the user to download a huge js-file with the coordinates?

Thanks! Ron


Solution

  • You can encode the polygon points to vastly reduce the size of the javascript file. To do this, you must include the geometry library.

    https://developers.google.com/maps/documentation/javascript/reference#encoding

    https://developers.google.com/maps/documentation/javascript/geometry#Encoding