I would like to automate the process of finding the closest train station's name to a given address (server side).
To state it another way, I would like to write a function that given any location string X, it returns the station name string Y.
I have experience with google map's API but I have not found a way to do this.
Just the name is enough information, but any amount of information or a list of the closest stations is OK, as long as I can confirm the closest one on the list.
I would like to automate the process of finding the closest train station's name to a given address (server side).
To state it another way, I would like to write a function that given any location string X, it returns the station name string Y.
I have experience with google map's API but I have not found a way to do this.
Just the name is enough information, but any amount of information or a list of the closest stations is OK, as long as I can confirm the closest one on the list.
Share Improve this question edited Jul 1, 2018 at 10:14 xomena 32.2k6 gold badges96 silver badges125 bronze badges asked May 13, 2018 at 5:43 Andy MacAndy Mac 3792 silver badges9 bronze badges1 Answer
Reset to default 6You can use a Places API web service to get nearest train station. For this purpose you can use nearby search functionality. For example, I have coordinate 45.77940539999999,15.9516292
and want to find a nearest train station.
Using web service request
https://maps.googleapis./maps/api/place/nearbysearch/json?location=45.77940539999999%2C15.9516292&rankby=distance&type=train_station&key=YOUR_API_KEY
you will get the nearest train station with name Remetinec as shown in my screenshot
As your intention is to implement this in server-side NodeJs, you can use the Node.js client library for Google Maps API Web Services
https://github./googlemaps/google-maps-services-js
The documentation is located at
https://googlemaps.github.io/google-maps-services-js/docs/GoogleMapsClient.html
Have a look at the placesNearby(query, callback)
method.
I hope this helps!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744291638a4567059.html
评论列表(0条)