Google路线服务提供错误的路线 [英] Google Direction service giving wrong route
问题描述
在具有以下坐标的地图上绘制googlemap路线.但是路线错误.问题出在哪里?
LNG LAT58.5589893333333 23.6229513333333开始58.5589985 23.6231225方式点158.5591366666667 23.6235491666667 WAY POINT 258.55882 23.6236481666667航点358.5476361666667 23.6209141666667航点458.5454098333333 23.616038结束
错误的路线
在Google地图网站中尝试使用相同的坐标,这给出了正确的方法
问题出在哪里?正确发送所有航路点,起点和目的地.坐标来自跟踪设备.仅在某些情况下显示这样的错误路线.
var directionDisplay;vardirectionService =新的google.maps.DirectionsService();directionsDisplay = new google.maps.DirectionsRenderer();directionsDisplay.setMap(map);var first = new google.maps.LatLng(23.6231225,58.5589985);var second = new google.maps.LatLng(23.6235491666667,58.5591366666667);var third = new google.maps.LatLng(23.6236481666667,58.55882);var forward = new google.maps.LatLng(23.6209141666667,58.5476361666667);var i = 0;var start = StartlatDir [i] +','+ StartlongDir [i];var end = EndlatDir [i] +','+ EndlongDir [i];var request = {来源:开始,目的地:结束,航点:[{位置:第一,中途停留:假},{位置:第二,中途停留:假},{位置:第三,中途停留:假},{location:第四,中途停留:false}],optimizeWaypoints:否,travelMode:google.maps.DirectionsTravelMode.DRIVING,unitSystem:google.maps.UnitSystem.METRIC};DirectionsService.route(要求,功能(回应,状态){如果(状态== google.maps.DirectionsStatus.OK){directionsDisplay.setDirections(response);var myRoute = response.routes [0];var txtDir ='';for(var i = 0; i< myRoute.legs [0] .steps.length; i ++){txtDir + = myRoute.legs [0] .steps [i] .instructions +< br/>";}}});
DirectionsService对出口附近(或道路错误的一侧)附近的航路点非常敏感.
Waypoint 4 (23.6209141666667,58.5476361666667)
使路线离开出口.
将其沿(23.620315,58.5471)
的路径进一步移动即可得出预期的路线:
或将其完全删除即可获得预期的路线
Drawing googlemap route on map with below coordinates.But getting wrong route. Where is the issue?
LNG LAT
58.5589893333333 23.6229513333333 Start
58.5589985 23.6231225 WAY POINT 1
58.5591366666667 23.6235491666667 WAY POINT 2
58.55882 23.6236481666667 WAY POINT 3
58.5476361666667 23.6209141666667 WAY POINT 4
58.5454098333333 23.616038 END
the wrong route
Same coordinates tried in Google map website,It is giving correct way
Where is the problem? Sending all the waypoints, origin and destination correctly. The coordinates are from tracking devices. only some cases showing wrong route like this.
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
var first = new google.maps.LatLng(23.6231225,58.5589985);
var second = new google.maps.LatLng(23.6235491666667,58.5591366666667);
var third = new google.maps.LatLng(23.6236481666667,58.55882);
var forth = new google.maps.LatLng(23.6209141666667,58.5476361666667);
var i = 0;
var start = StartlatDir[i]+','+StartlongDir[i];
var end = EndlatDir[i] + ',' + EndlongDir[i];
var request = {
origin: start,
destination: end,
waypoints: [{ location:first, stopover: false },
{ location: second, stopover: false },
{ location: third, stopover: false },
{ location: forth, stopover: false }],
optimizeWaypoints: false,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
var myRoute = response.routes[0];
var txtDir = '';
for (var i = 0; i < myRoute.legs[0].steps.length; i++) {
txtDir += myRoute.legs[0].steps[i].instructions + "<br />";
}
}
});
The DirectionsService is very sensitive to waypoints near exits (or on the wrong side of the road).
Waypoint 4 (23.6209141666667, 58.5476361666667)
makes the route take the exit.
Moving it further along the road to (23.620315,58.5471)
gives the expected route:
or removing it completely gives the expected route
这篇关于Google路线服务提供错误的路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!