嗨伙伴我在我的谷歌地图中使用多边形线但是我在使用它时遇到了一些问题。
flightPlanCoordinates = [new google.maps.LatLng(30.265944, 78.0558291),new google.maps.LatLng(30.75, 76.78)];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
这段代码完美无缺,但是当我以这种方式更改此代码时,它不会在两个坐标之间设置行
for (i = 0; i < size; i++) {
flightPlanCoordinates[i] = [new google.maps.LatLng(msg.coordinates[i].latitude, msg.coordinates[i].longitude)];
}
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
请提前帮助我..
答案 0 :(得分:1)
for (i = 0; i < size; i++) {
flightPlanCoordinates[i] = [new google.maps.LatLng(msg.coordinates[i].latitude, msg.coordinates[i].longitude)];
}
只需从下面给出的代码中更改这一个代码
for (i = 0; i < size; i++) {
flightPlanCoordinates[i] = new google.maps.LatLng(msg.coordinates[i].latitude, msg.coordinates[i].longitude);
}
让我知道它是否有效