heremaps/maps-api-for-javascript-examples

platform.getSearchService Browse "In" parameter not functioning correctly?

rbed23 opened this issue · 5 comments

I am attempting to return a list of places located within a circle object that Ive created for my map... Ive read the documentation, it explicitly states using an 'in' or 'at' parameter in my call to /browse, however I get the following response from the API gateway...

https://browse.search.hereapi.com/v1/browse?
  apikey={my api key}
  &in=circle:27.70525,85.28686;r=50
  &limit=100
  &categories=100-1100

status | 400
title | "Required parameter 'at' is missing"
correlationId | "de7d83c0-cff8-4e18-8201-865a0db2f210"
requestId | "REQ-07a1b42f-1f18-4b64-b675-8d3361ed01fb"

I get the same response from my code...

function getMiddleResults(circle) {
  var resultsService = platform.getSearchService()
  resultsService.browse({
       in: 'circle:' + circle.b.lat + ',' + circle.b.lng + ";r=" + circle.sa,
       limit: 10,
       categories: '100-1100'
   }, console.log, console.error);
}

Error: "Required parameter 'at' is missing"
c https://js.api.here.com/v3/3.1/mapsjs-core.js line 71 > eval:139
O https://js.api.here.com/v3/3.1/mapsjs-core.js line 71 > eval:3

When I add the 'at' parameter with the lat/lng position, the results returned are outside the defined circle radius value

Can you please send the documentation link where it is stated that in is supported parameter?
Geocoding and Search API /browse documentation says that /browse endpoint returns results at the specified position within radius of 250km.

Maybe you want to use /discover endpoint instead? It supports in parameter: Geocoding and Search API /discover

H.service.Platform#getSearchService returns H.service.SearchService which communicates with Geocoding and Search REST API.

The link you provided is for Places API rest service, which isn't actively developed anymore, so I would use Geocoding and Search REST API instead.
If you really want to use the Places API rest service, then your code should look like this:

function getMiddleResults(circle) {
  var resultsService = platform.getPlacesService();

  resultsService.request('browse', {
       in: circle.getCenter().lat + ',' + circle.getCenter().lng + ";r=" + circle.getRadius(),
       limit: 10,
       cat: '100-1100'
   }, console.log, console.error);
}

Ok - thank you. Sorry about my confusion...

For my application, if I need to browse ALL places of a certain category(s), located specifically within a given circle (using the SearchService REST API), what methods would you suggest?

From /browse, are the returned distance values a simple geo-distance calculation ('as the crow flys') from the supplied AT value? If so, I could then just filter out all places with distance > radius... but I could miss some places of interest if my LIMIT isnt set correctly (always needing to set LIMIT >> than I actually need...)

Or is it generated by some other distance calculation (eg a 'route' distance)? Thanks!

Hello. Sorry for the late reply.
If you really need to search within a given circle, then you still can use Places API with the code I provided. This API isn't deprecated, just not actively developed.

It seems that new Geocoding and Search REST API doesn't have this option and you would exactly need to filter by a distance values. It should be simple geo-distance calculation (no routing)