我目前正在使用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.')
}
});