【发布时间】:2016-12-02 12:26:09
【问题描述】:
enter image description here 我是谷歌 API 的新手。请帮我通过动态传递坐标数组来使用谷歌地图折线API?
【问题讨论】:
-
代码图片无用,请提供minimal reproducible example 说明问题。
标签: google-maps google-maps-api-3 polyline
enter image description here 我是谷歌 API 的新手。请帮我通过动态传递坐标数组来使用谷歌地图折线API?
【问题讨论】:
标签: google-maps google-maps-api-3 polyline
制作 latlng 数组,然后在折线 obj 中使用该数组路径
var latlngArray = [[lat,lng],[lat,lng],[lat,lng],[lat,lng]];
var patharray = [];
for (var i = 0;i<latlngArray .length ;i++){
patharray.push(new google.maps.LatLng(latlngArray[i][0],latlngArray[i][1]));
}
var tourplan = new google.maps.Polyline({
path : patharray ,
strokeColor : "#0000FF",
strokeOpacity : 0.6,
strokeWeight : 2,
});
tourplan.setMap(map)
【讨论】: