0

我有一个 api3 地图,它使用

var orchards = new google.maps.LatLng(52.512565,-2.7595);

我想添加“获取路线”,它的工作正常,只是它在一个稍微不同的地方结束。方向结束于沿路约 100 米处的一所房子 - 不是地图的纬度/经度所在的位置。宾馆的邮政编码是 SY6 7DQ,但方向的终点是 SY6 7DG

我怎样才能得到在正确的地方结束的方向。

你可以在这里看到我的意思:http: //www.dev.ee-web.co.uk/orchards/index.php ?option=com_content&view=article&id=6&Itemid=106

这是我正在使用的功能:

 function calcRoute() {
directionsVisible=true;
//  alter print text
document.getElementById('printMe').innerHTML = " Print directions";

// remove marker
marker.setMap(null);     
var start = document.getElementById("startFrom").value;
var end = "52.512565,-2.7595";
var request = {
    origin:start, 
    destination:end,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
  if (status == google.maps.DirectionsStatus.OK) {
    directionsDisplay.setDirections(response);
  }
});

}

我尝试将正确的邮政编码放入谷歌地图,但产生的数字仍然指向错误的地方。

我真的很感激任何帮助

谢谢

4

1 回答 1

1

当您在道路上指定 LatLng 时,看起来方向非常准确。我的猜测是最初的结果并不令人满意,因为标记不在路上。

转到此页面并单击您希望路线结束的道路并从右侧复制 latLng 值。粘贴到您的var end = ...我建议保存精度。

https://files.nyu.edu/hc742/public/googlemaps/geocodeUK.html

于 2012-04-12T16:58:56.797 回答