Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在google maps api中从多边形中删除面积_Javascript_Google Maps_Polygons - Fatal编程技术网

Javascript 如何在google maps api中从多边形中删除面积

Javascript 如何在google maps api中从多边形中删除面积,javascript,google-maps,polygons,Javascript,Google Maps,Polygons,我有两个多边形的坐标(P1和P2)在谷歌地图上创建它。当P2位于P1中时,如何从P1切割P2? 比如说 这是我的js: var triangleCoords = [ new google.maps.LatLng(25.774252, -80.190262), new google.maps.LatLng(18.466465, -66.118292), new google.maps.LatLng(32.321384, -64.75737), new google.

我有两个多边形的坐标(P1和P2)在谷歌地图上创建它。当P2位于P1中时,如何从P1切割P2? 比如说

这是我的js:

var triangleCoords = [
    new google.maps.LatLng(25.774252, -80.190262),
    new google.maps.LatLng(18.466465, -66.118292),
    new google.maps.LatLng(32.321384, -64.75737),
    new google.maps.LatLng(25.774252, -80.190262)
];
var triangleCoords1 = [
    new google.maps.LatLng(29,-69),
    new google.maps.LatLng(23,-72),
    new google.maps.LatLng(25,-70),
    new google.maps.LatLng(29,-69)
];
bermudaTriangle = new google.maps.Polygon({
    paths: [triangleCoords, triangleCoords1],
    strokeColor: '#FF0000',
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: '#FF0000',
    fillOpacity: 0.35
});
bermudaTriangle.setMap(map);

需要使内部多边形的缠绕方向与外部多边形的缠绕方向相反

代码段:

var映射;
函数初始化(){
map=新建google.maps.map(
document.getElementById(“地图画布”){
中心:新google.maps.LatLng(37.4419,-122.1419),
缩放:13,
mapTypeId:google.maps.mapTypeId.ROADMAP
});
var bounds=new google.maps.LatLngBounds();
var triangleCoords=[
新的google.maps.LatLng(25.774252,-80.190262),
新google.maps.LatLng(18.466465,-66.118292),
新的google.maps.LatLng(32.321384,-64.75737),
新google.maps.LatLng(25.774252,-80.190262)
];
变量triangelecoords1=[
新的google.maps.LatLng(29,-69),
新的google.maps.LatLng(25,-70),
新的google.maps.LatLng(23,-72),
新google.maps.LatLng(29,-69)
];
对于(变量i=0;i
html,
身体,
#地图画布{
身高:100%;
宽度:100%;
边际:0px;
填充:0px
}