<script type="text/javascript">
$("#test").gmap3({
getroute:{
options:{
origin:"Trenggalek, Indonesia",
waypoints: [{location: "Blitar, Indonesia", stopover: false},{location: "Malang, Indonesia", stopover: false}],
destination:"Surabaya, Indonesia",
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results){
if (!results) return;
$(this).gmap3({
map:{
options:{
zoom: 13,
center: [-33.879, 151.235]
}
},
directionsrenderer:{
options:{
directions:results
}
}
});
}
}
});
</script>
但是当我用纬度和经度改变位置然后发生错误
waypoints: [{location: "Blitar, Indonesia", stopover: false},{location: [-7.988518,112.619262], stopover: false}],
如何使用纬度和经度更改位置?
答案 0 :(得分:1)
如果location是坐标,则需要是google.maps.LatLng对象,而不是数字数组。请阅读文档。
https://developers.google.com/maps/documentation/javascript/reference#DirectionsWaypoint
变化:
waypoints: [{location: "Blitar, Indonesia", stopover: false},{location: [-7.988518,112.619262], stopover: false}],
为:
waypoints: [{location: "Blitar, Indonesia", stopover: false},{location: new google.maps.LatLng(-7.988518,112.619262), stopover: false}],