smeijer / leaflet-geosearch

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

Google Provider is not working #399

Open ffkarine opened 3 months ago

ffkarine commented 3 months ago

Hello. I'm trying to incorporate search in my map using the Google Provider, however I'm not able to make it work. My code is very direct:

        const searchControl = new GeoSearch.GeoSearchControl({
            provider: new GeoSearch.GoogleProvider({
                apiKey: 'MY_GOOGLE_API_KEY'}),
            position: 'topright',
            style: 'bar',
            // provider: new GeoSearch.OpenStreetMapProvider(),
        });

        map.addControl(searchControl);

If I use the OSM provider (commented out in the code above), the search works fine (the results are kind of obsolete for my region, but it works) (Figure 1) . But if I use the Google Provider, nothing appears as a result of the search (Figure 2).

image

image

Some more details:

fernandoqqq commented 3 months ago

Try changing apiKey to key

geoffreys commented 2 months ago

Experiencing the same issue, have tried both key and apiKey. Also same issue hitting the provider directly with await provider.search({ query: "the query" });