2013-12-14 12 views
0
<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> 

但是,當我改變位置與lattitude和經度,然後發生錯誤getroute使用航點錯誤gmap3 jQuery插件

waypoints: [{location: "Blitar, Indonesia", stopover: false},{location: [-7.988518,112.619262], stopover: false}], 

如何使用lattitude和緯度來改變位置?

回答

1

如果位置是座標,它需要是一個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}], 

working fiddle