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

Search fails when address begins with place name instead of number. #205

Closed johntyree closed 4 years ago

johntyree commented 4 years ago

E.g. type 1600 amphitheatre parkway and it will (correctly) suggest Google Headquarters, 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA, but if you click it, it fails to move the map. If you remove the Google Headquarters prefix, it works. So 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA is fine.

Same thing happens if you search for noisebridge and choose Noisebridge, 2261, Mission Street, Mission District, San Francisco, San Francisco City and County, California, 94110, USA from the results. Removing "Noisebridge" works, so 2261, Mission Street, Mission District, San Francisco, San Francisco City and County, California, 94110, USA is fine.

The real problem is that it doesn't output any kind of error or give you any clue that you need to modify the address to get the search to work correctly.

smeijer commented 4 years ago

This seems to have something to do with the provider. Can you check if the search query that doesn't work, even returns a geometry?

johntyree commented 4 years ago

It looks like it?

$ curl -sL 'https://nominatim.openstreetmap.org/search?format=json&q=1600%20amphitheatre%20parkway' | python -m json.tool
[
    {
        "boundingbox": [
            "37.4217136",
            "37.4218136",
            "-122.084664",
            "-122.084564"
        ],
        "class": "office",
        "display_name": "Google Headquarters, 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA",
        "importance": 0.31100000000000005,
        "lat": "37.4217636",
        "licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",                        
        "lon": "-122.084614",
        "osm_id": 2192620021,
        "osm_type": "node",
        "place_id": 22513380,
        "type": "commercial"
    },
    {
        "boundingbox": [
            "37.4221124",
            "37.4228508",
            "-122.0859868",
            "-122.0851511"
        ],
        "class": "building",
        "display_name": "Google Building 41, 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA",
        "importance": 0.31100000000000005,
        "lat": "37.42248575",
        "licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",                        
        "lon": "-122.085584566136",
        "osm_id": 23733659,
        "osm_type": "way",
        "place_id": 80280201,
        "type": "yes"
    }
]
smeijer commented 4 years ago

Thanks. I got it.

Steps to reproduce:

1. Search for: 1600 amphitheatre parkway

   -> Provider runs first query for 
        1600 amphitheatre parkway

   -> API returns suggestions: 
        1. Google Headquarters, 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA
        2. Google Building 41, 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA

2. Select first suggestion:

   -> Provider runs a second query for 
        1. Google Headquarters, 1600, Amphitheatre Parkway, Mountain View, Santa Clara County, California, 94043, USA

   -> API returns empty result.
smeijer commented 4 years ago

Labeled as enhancement and not as bug, as we might fix this by removing the second query. This however needs some thorough testing.

I don't see it as a bug for leaflet-geosearch, as it's strange that openstreetmap provides us a result, but doesn't recognize it when we search for that exact phrase.

johntyree commented 4 years ago

That is strange. Do you happen to know the right place to file a bug upstream? leaflet-geosearch is not the right place to fix this.

smeijer commented 4 years ago

Based on the discussion above, I'm closing this one in favor of #180.