我可以通过以下方式使用Google Maps API来获取某个位置附近的火车站集:
var request = {
location : new google.maps.LatLng( 40.7829, 73.9654) ,
radius : 500,
type : [ "subway_station"]
};
var callback = function( results, status )
{
if( status === 'OK')
{
console.log( results );
}
else
console.log("Unable to get nearby places at this time...");
};
var placeService = new google.maps.places.PlacesService( map );
placeService.nearbySearch( request, callback );
返回以下记录:
{
"geometry" : {
"location" : {
"lat" : 40.7829,
"lng" : -73.9654
},
"viewport" : {
"northeast" : {
"lat" : 40.7106958302915,
"lng" : -73.81892516970849
},
"southwest" : {
"lat" : 40.7079978697085,
"lng" : -73.8216231302915
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "3d01401185776e41c01a4c211dca4d49319343f9",
"name" : "Briarwood - Van Wyck Blvd",
"photos" : [
{
"height" : 2826,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101580679594295106213/photos\"\u003eJay Kindell\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh3.googleusercontent.com/p/AF1QipPfK--UgtYinCZOMzuBhDlXg-567SVObqpV8OU=k"
},
"width" : 2474
}
],
"place_id" : "ChIJL_WID79gwokR1C9hMstDeUU",
"rating" : 3.5,
"reference" : "CmRRAAAA8187TUFA1CrDZaHYUihPHfW3XNfBdXOyVng3cWkaOLGw2b2LEfweAqYj09PnRb0BPmSyp8wgeKkbG-RfD8uC6fA9KzZv_TOsvJWLiyj-K52gSuDCYg83RyqBR1QReO8AEhCx7aYumeiOv00Zlw_B4xc-GhR3OTWRrHo6sC2XeMQWrolrIFGszg",
"scope" : "GOOGLE",
"types" : [
"subway_station",
"transit_station",
"point_of_interest",
"establishment"
],
"vicinity" : "&, Queens Boulevard & Main Street, New York"
},
尽管API为我提供了附近的所有火车站,但它并没有告诉我哪些列车都在这些火车站。例如,Briarwood地铁站的上述记录有E和F列车,但记录中没有这些信息。有没有办法获得这些信息?我可以在Google地图上看到这些信息: