Leticia Esperon
Leticia Esperon

Reputation: 2841

Restrict geocoder results to a country or city

I've been using Ruby gem Geocoder version 1.3 to find coordinates of an address. I need to restrict all results to a certain city or at least country because I'm getting most of the geolocalizations wrong.

I'm using Google for the search.

I tried for example:

Geocoder.search('Juan Cayetano Molina 450', params: { region: 'UY', components: 'country|UY'})

but I still get results in a different country. I also tried in params sending in location, country, etc. but no luck either.

I don't want to concat the city name to the search term because I'm getting as result the center of the city which is not what I wanted.

Can someone help me? Seems so simple but I couldn't find any answer that worked for me.

Upvotes: 1

Views: 422

Answers (1)

Viseshini Reddy
Viseshini Reddy

Reputation: 819

You can use Geocoder.search("Juan Cayetano Molina 450", params: {countrycodes: "uy"}) instead.

Upvotes: 2

Related Questions