nchaulet / node-geocoder

nodejs geocoding library
http://nchaulet.github.io/node-geocoder/
MIT License
928 stars 214 forks source link

Google reverse geocoder only uses the first result #264

Open Wardormeur opened 5 years ago

Wardormeur commented 5 years ago

Hi :) First of all, thanks for your work on this lib! We've been using Google reverse geocoding for several usage, and we've felt short in a scenario : administrative levels are sometime not being outputted. The reason for that is that when multiple rows are being returned, only one is being used (https://github.com/nchaulet/node-geocoder/blob/master/lib/geocoder/googlegeocoder.js#L298). The issue with that is that for { lat: 53.61748476104803, lon: -2.1537119150161743 } for example, the administrative levels are being set in the following rows, which looks like higher level matches. My solution would be to reduce the address_components and assign them to the single result row before passing it to _formatResult. For anybody, if that's considered a non-issue, you can still retrieve the information from the result.raw, but that becomes a manual parsing.

ruscon commented 5 years ago

You can try a new library https://github.com/goparrot/geocoder