Reputation: 1156
I noticed when drawing polygons with the Drawing Manager they are not closed (i.e. no coordinates for the last point to the first).. I know Google Maps API v3 will automatically close the polygon but Google Earth, Google Static Maps API or any other software I try to import the data into..
My problem is, I use the geometry lib to save encoded polygons.. Is there any way to push a copy of the first point to the last in the overlays object before encoding?
My work around is to getPaths().getArray() to my own array, make the copy and then use a javascript lib to encode which works ok but is a lot of code.. Just wondering if there is an easier way?
Upvotes: 4
Views: 2469
Reputation: 161334
Something like this should add the first point of the polygon to the end of the MVCArrry (not tested).
myPoly.getPath().push(getPath().getAt(0));
(assumes a simple polygon with one path, getPath returns the first path)
Upvotes: 5