Google Maps API v3多边形关闭 [英] Google Maps API v3 Polygon closing

查看:141
本文介绍了Google Maps API v3多边形关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Google Maps API v3创建多边形时,如何防止多边形贴合到其他地图?

因此,而不是:

我想使多边形关闭像这样:


<当路径中两个连续点的经度之间的差异> = 180时,就会出现这个问题。b
$ b

前两点的经度是-97和93,所以这就是这种情况的问题(相差190)

到目前为止,我可能会提出的唯一建议是分开这部分路径:

  new google.maps.LatLng(81,-97),
/ /额外点
新google.maps.LatLng(80.5,-12),
新google.maps.LatLng(80,93),
新google.maps.LatLng(56,78 ),
new google.maps.LatLn g(60,-94)

演示: http://jsfiddle.net/doktormolle/39CtV/

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

So instead of:

I would like to make the polygon close like this:

解决方案

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/

这篇关于Google Maps API v3多边形关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆