Google Maps API v3 directions.route()请求

时间:2010-11-11 20:33:01

标签: javascript google-maps

我一直在转换为Google Maps API的第3版,并在调用directionsService.route()时不断收到错误。地图渲染得很好,但在Firebug中我看到google抛出错误“a is undefined(main.js line 16)”。

以下是相关代码:

self.gmap = new google.maps.Map(document.getElementById(id),mapOpts);

self.dirService = new google.maps.DirectionsService(self.gmap);

self.dirRenderer = new google.maps.DirectionsRenderer({
                draggable: false,
                map: self.gmap,
                markerOptions: {clickable: false}});

//定义原点,目的地等......

self.dirService.route({
'destination' : destination,
'origin' : origin,
'travelMode' : google.maps.DirectionsTravelMode.DRIVING
},function(result,status){
if(status == google.maps.DirectionsStatus.OK){
    self.dirRenderer.setDirections(result);
    self.refreshMap();
} else {
    alert(self.ERR_MapRoute);
}
});

在API文档中,Google表示路线请求中只需要origin,destination和travelMode。有没有人遇到过这个问题?

1 个答案:

答案 0 :(得分:0)

我曾经使用地图上没有的叠加层来获取此错误。或者初始化出错了。 检查你的初始化,你可能错过了一些东西。

相关问题