Google maps 谷歌地图API多边形,带;“洞”;居中

Google maps 谷歌地图API多边形,带;“洞”;居中,google-maps,google-maps-api-3,polygon,Google Maps,Google Maps Api 3,Polygon,在另一个多边形中插入一个多边形应该在中心形成一个“洞”(参见谷歌地图五角大楼示例)。然而,我的程序始终无法生成一个孔,而是生成两层插入的多边形线 这实际上是多边形中索引的方向问题,一个是顺时针方向,另一个应该是逆时针方向。 将第二个阵列更改为: var circleOverlay = [ new google.maps.LatLng(25.774252, -80.190262), new google.maps.LatLng(32.321384, -64.75737), //sec

在另一个多边形中插入一个多边形应该在中心形成一个“洞”(参见谷歌地图五角大楼示例)。然而,我的程序始终无法生成一个孔,而是生成两层插入的多边形线


这实际上是多边形中索引的方向问题,一个是顺时针方向,另一个应该是逆时针方向。 将第二个阵列更改为:

var circleOverlay = [
   new google.maps.LatLng(25.774252, -80.190262),
   new google.maps.LatLng(32.321384, -64.75737),  //second and third coordinates
   new google.maps.LatLng(18.466465, -66.118292), //are swapped compared to your original
   new google.maps.LatLng(25.774252, -80.190262)
 ];
它会在你的三角形上显示一个漂亮的洞

var circleOverlay = [
   new google.maps.LatLng(25.774252, -80.190262),
   new google.maps.LatLng(32.321384, -64.75737),  //second and third coordinates
   new google.maps.LatLng(18.466465, -66.118292), //are swapped compared to your original
   new google.maps.LatLng(25.774252, -80.190262)
 ];