Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API v3 Polygon closing

When creating a polygon using the Google Maps API v3, how can I prevent the polygon from snapping to other 'maps'?

So instead of: enter image description here

I would like to make the polygon close like this: enter image description here

like image 518
Laurent Avatar asked Apr 21 '26 04:04

Laurent


1 Answers

The issue occurs when the difference between the longitudes of 2 consecutive points in the path is >=180

the longitudes of the first 2 points are -97 and 93, so that's the problem in this case(difference is 190)

The only thing I may suggest so far is to split this portion of the path:

new google.maps.LatLng(81, -97),
//additional point
new google.maps.LatLng(80.5, -12),
new google.maps.LatLng(80, 93),
new google.maps.LatLng(56, 78),
new google.maps.LatLng(60, -94)

Demo: http://jsfiddle.net/doktormolle/39CtV/

like image 115
Dr.Molle Avatar answered Apr 23 '26 18:04

Dr.Molle