GeoDB Cities

FREEMIUM
Verified
By Michael Mogley | Updated a month ago | Data
Popularity

9.9 / 10

Latency

52ms

Service Level

100%

Health Check

100%

Back to All Discussions

Advanced request

Rapid account: Simon Mercier 59
simon.mercier59
5 years ago

Hello,

I would like to do this search :
Find cities :

  • near my location AND
  • in my country AND
  • sort them by distance

It seems that it is NOT possible to

  • add the parameters “countryIds” and “location” in the same request
  • sort by distance

Am I right ?

Would it be possible to add this search criteria ?

Thanks

Rapid account: Wirefreethought
wirefreethought Commented 5 years ago

Hmmm. Why can’t you just do a single request without the country filters, then filter by country on the client side once you get the results? That should be more efficient I would think.

Rapid account: Simon Mercier 59
simon.mercier59 Commented 5 years ago

Thanks, I will try it and let you know.
My need is to do an autocomplete search view like google maps… I am trying to do a smart algorithm.

Currently I am doing 2 requests :

  • find cities in a radius -> exclude the one which are not in the user’s country + sort them by distance (because the radius is large)
  • find cities in all the world and sort them by population
    Then I reorder them according to the user’s query.

I am assuming that the city the user is searching for should be in the first request. The second request is here in case of the user search for a city in a foreign country.
It is far to be as efficient as google maps but the results are quite correct.

Rapid account: Wirefreethought
wirefreethought Commented 5 years ago

This has been deployed! New params, countryIds and excludedCountryIds, now available for this endpoint. Try it out.

Rapid account: Wirefreethought
wirefreethought Commented 5 years ago

My thinking at the time was that users looking to sort cities by distance from a location probably wouldn’t care which country those cities were in, Guess I was wrong 😃 I will add this in the coming days and let you know.

Join in the discussion - add comment below:

Login / Signup to post new comments