Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.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 谷歌地图多段线_Javascript_Jquery_Google Maps_Google Polyline - Fatal编程技术网

Javascript 谷歌地图多段线

Javascript 谷歌地图多段线,javascript,jquery,google-maps,google-polyline,Javascript,Jquery,Google Maps,Google Polyline,我有一个包含多个多边形的图形。我将新的google.maps.Polygon函数更改为polyline as new google.maps.Polyline({ paths: arr, strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 2, fillColor:

我有一个包含多个多边形的图形。我将
新的google.maps.Polygon
函数更改为polyline as

     new google.maps.Polyline({
                paths: arr,
                strokeColor: '#FF0000',
                strokeOpacity: 0.8,
                strokeWeight: 2,
                fillColor: '#FF0000',
                fillOpacity: 0.35
            })
但它并没有划清界限。以及如何将对象名称设置为infowindow内容。我试过了

 var infowindow = new google.maps.InfoWindow({
            content: i
        });

.google.maps.Polyline没有路径属性。更改:

 new google.maps.Polyline({
            paths: arr,
            strokeColor: '#FF0000',
            strokeOpacity: 0.8,
            strokeWeight: 2,
            fillColor: '#FF0000',
            fillOpacity: 0.35
        })
致:

代码片段:

var映射,信息窗口;
函数初始化(){
变量映射选项={
缩放:5,
中心:新google.maps.LatLng(24.886436490787712,-70.2685546875),
mapTypeId:google.maps.mapTypeId.TERRAIN
};
var bounds=new google.maps.LatLngBounds();
var=[];
var arr=新数组();
var map=new google.maps.map(document.getElementById('map-canvas'),
地图选项);
//定义多边形路径的板条坐标。
变量坐标={
“feed1”:[
[25.774252, -80.190262],
[18.466465, -66.118292],
[32.321384, -64.75737],
[25.774252, -80.190262]
],
“feed2”:[
[26.774252, -81.190262],
[19.466465, -67.118292],
[33.321384, -65.75737],
[26.774252, -81.190262]
],
“feed3”:[
[27.774252, -82.190262],
[20.466465, -68.118292],
[34.321384, -66.75737],
[27.774252, -82.190262]
]
};
用于(坐标中的变量i){
arr=[];
对于(var j=0;j<坐标[i]。长度;j++){
arr.push(新的google.maps.LatLng)(
parseFloat(坐标[i][j][0]),
parseFloat(坐标[i][j][1])
));
bounds.extend(arr[arr.length-1])
}
//构造多边形。
polygons.push(新的google.maps.Polyline({
路径:arr,
strokeColor:“#FF0000”,
笔划不透明度:0.8,
冲程重量:2,
填充颜色:'#FF0000',
不透明度:0.35
}));
多边形[polygons.length-1].setMap(map);
var infowindow=new google.maps.infowindow({
内容:“你好,世界!”
});
google.maps.event.addListener(多边形[polygons.length-1],“单击”,函数(事件){
打开(地图);
infowindow.setPosition(event.latLng);
});
}
映射边界(bounds);
//google.maps.event.addListener(arr,'click',showArrays);
//infoWindow=new google.maps.infoWindow();
}
/*
函数ShowArray(事件){
var contentString='百慕大三角多边形
'; //替换信息窗口的内容和位置。 setContent(contentString); //infoWindow.setPosition(event.latLng); 打开(地图); } */ google.maps.event.addDomListener(窗口“加载”,初始化)
html,
身体,
#地图画布{
身高:100%;
边际:0px;
填充:0px
}

作为新问题提问
 new google.maps.Polyline({
            path: arr,
            strokeColor: '#FF0000',
            strokeOpacity: 0.8,
            strokeWeight: 2,
            fillColor: '#FF0000',
            fillOpacity: 0.35
        })