Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Provider is not working #399

Open
ffkarine opened this issue Mar 26, 2024 · 2 comments
Open

Google Provider is not working #399

ffkarine opened this issue Mar 26, 2024 · 2 comments

Comments

@ffkarine
Copy link

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:

  • Both the Maps JS API and the Geocoding API are enabled on the Google Console (BTW, for the GridLayer I'm using GoogleMutant which uses the API key and it's working flawless);
  • The API key is not under any restriction in the Google Console, since I'm only testing this integration for now;
  • The browser console outputs this:
    image
    I don't think it is related to this problem, but I guess it doesn't hurt to mention it.
@fernandoqqq
Copy link

Try changing apiKey to key

@geoffreys
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants