我在我的网站上有谷歌地图V3,并试图获得两个地方之间的方向,其中我将传递一个地址作为文本,另一个地址的纬度和经度到谷歌路线函数,如下所示:
oRequest = {
origin: address in string text format,
destination: latlng object,
travelMode: google.maps.TravelMode.DRIVING
};
g_oDirections.route(oRequest, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
g_oDirectionsDisplay.setDirections(response);
}
else { CreateDefaultMap(); }
});
它在google返回的html集合中显示了错误的文本(目的地),这将显示文本A和B(目的地),中间有一些路点。
当我在google地图中尝试同样的方法并且运行良好时,我调试了我所有的代码,直到调用google api函数一切都很好,将latlng对象和address作为文本传递。
任何关于plz的工作..
发布于 2013-07-16 09:51:52
看看这个jsFiddle,它对我很有效。
var start = "Brno"; //Set the source/ origin
var end = new google.maps.LatLng(50, 15); //Set the destination
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
也许你发送给方向服务的特定地点有问题。我有过几次这样的问题。如果是这样的话,发布位置和坐标。
https://stackoverflow.com/questions/17673137
复制