I'm asking if it's possible to order results by distance in a Discover
query. I've performed a query for train stations however, the results seem to order somewhat randomly. I'm only interested in what the nearest train station is and so having a result with the nearest distance first would be valuable.
I appreciated that it's entirely possible to programmatically achieve this, but before I burn time working on a solution, I figured it was worth reaching out to see if this was already possible within the API.
If it helps, this is the query I was making https://discover.search.hereapi.com/v1/discover?at=-34.0337365,151.0847004&q=station&limit=10&apikey=
. You may see that the closest result is 4th down.
Happy to hear an alternative solution if there is one.
Thanks!
You can do this in two different ways.
Use the browse
endpoint instead of discover
and the results will be arranged according to distance. The code will look like:
https://browse.search.hereapi.com/v1/browse?at=-34.0337365,151.0847004&name=station&limit=10&apikey=
OR
Places category system https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics-places/places-category-system-full.html