Google Maps Route API V3:特定位置的错误,仅在设置为目标时?

时间:2016-01-21 17:59:53

标签: google-maps google-maps-api-3

我目前正在使用Google Maps API查找两个地点之间的公交路线。它几乎在所有场合都能正常工作,除非目的地是Schiphol, Netherlands(荷兰国家机场)。

无论起始位置是什么,Google Maps API都找不到通往史基浦的任何公交路线。很奇怪,因为当我在http://maps.google.com输入完全相同的位置时,Google会发现很多路线。此外,当Schiphol, Netherlands为起点时,一切正常。

请参阅this JSFiddle或以下代码。

var directionsService = new google.maps.DirectionsService;

directionsService.route({
  origin: 'Rotterdam, Netherlands',
  destination: 'Schiphol, Netherlands', // Change this to e.g. 'The Hague, Netherlands' and it works.
  travelMode: google.maps.TravelMode.TRANSIT,
}, function(response, status) {
  if (status === google.maps.DirectionsStatus.OK) {
    var route = response.routes[0].legs[0];
    window.alert('When Schiphol is destination: noute found!')
  } else {
    window.alert('When Schiphol is destination: no transit routes found.')
  }
});

directionsService.route({
  origin: 'Schiphol, Netherlands',
  destination: 'Rotterdam, Netherlands',
  travelMode: google.maps.TravelMode.TRANSIT,
}, function(response, status) {
  if (status === google.maps.DirectionsStatus.OK) {
    var route = response.routes[0].legs[0];
    window.alert('When Schiphol is origin: route found!')
  } else {
    window.alert('When Schiphol is origin: no transit routes found.')
  }
});

0 个答案:

没有答案