smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.03k stars 273 forks source link

Google & Bing Autocomplete results differ from actual services #182

Open pixels-for-breakfast opened 5 years ago

pixels-for-breakfast commented 5 years ago

Hi,

Technically the autocomplete works quite well; it shows suggestions, even when I in some (not all) cases manage to apply a countrycode to narrow down the results. But the issue is that the results that are shown differ from the results that I get when searching on Google Maps or Bing Maps. This can be seen in the demo aswel. It only returns exact matches. Ie. searching for 'ber' will return a village called Bér in Hungary, or Ber in Senegal, India or Nepal. 'Berlin' on the other hand is not one of the results...

Any idea why this happens? Can it be fixed somehow?

Thanks

smeijer commented 5 years ago

No idea, we simply pas the arguments to the providers api endpoint. Perhaps it's because we use the searching api for auto completion, and not a dedicated auto completion api?

Can you get the "correct" predictions when you query the endpoint directly?

https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering

pixels-for-breakfast commented 5 years ago

Hi Stephan,

Thank you for replying on such short notice.

I've tried several endpoints, with various results. I have a hard time wrapping my head around it.

I reckon it will be hard to get this working for all/most providers, but at least Google would be really nice.

Thanks

smeijer commented 5 years ago

If I look at the jsfiddle, it's exactly what I said. We don't use a special 'autocomplete' service, we do a geocoding on the text you've entered so far.

So yes. Definitely something we could improve/implement. But also something that will require some work.

We need to separate autocompletion / geocoding logic for the providers that have a separate autocompletion api.

A PR is most welcome.

elixirdada commented 5 years ago

@smeijer, I am trying to integrate the geocoding on leaflet map. But I have some issues as following:

It is the searching result of leaflet: Screen Shot 2019-04-12 at 6 51 45 AM

And it is the result of searching using google map: Screen Shot 2019-04-12 at 6 53 10 AM

As you can see the getting addresses are different from each other even though the same position. How can I fix it?

smeijer commented 5 years ago

Those are different providers, which treat search queries differently. We can't control that. It's like using Google or Bing. Those return different search results on the same input.

That being said, when I compare both providers on this specific input, I'm having a very close match. The difference is just a few meters. So I'm not sure what exactly the problem is that you're experiencing. The only provider messing up this query, is the Esri provider.

leaflet-geosearch

You can try it on https://smeijer.github.io/leaflet-geosearch

smeijer commented 5 years ago

@pixels-for-breakfast , I've looked into your issue. And I think I've located it. The results you're referring to, are using the place api, and not the geocode api as this library does.

We could change that, to use the place for the predictions. But it's been a while since I've worked on this project. And checking the API, I found out that Google requires me to provide billing information to obtain an api key that can be used with the places api.

I'm a bit hesitant about doing that.

https://maps.googleapis.com/maps/api/place/autocomplete/json?key=__YOUR_KEY__&input=dorpsstraat
elixirdada commented 5 years ago

@smeijer That works for me. I have fixed that using get paid google API. Thanks.

And currently, I have another issue now using React leaflet map. So I am going to add the geo address in the marker tooltip below.

Screen Shot 2019-04-22 at 6 31 56 AM

How can I integrate it?