【问题标题】:getroute with waypoints error using gmap3 jquery plugin使用gmap3 jquery插件的getroute与航点错误
【发布时间】:2013-12-14 01:26:07
【问题描述】:
<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}],

如何使用经纬度改变位置?

【问题讨论】:

    标签: javascript jquery google-maps map


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-21
      • 1970-01-01
      • 2013-03-31
      • 1970-01-01
      • 2013-12-23
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      相关资源
      最近更新 更多