Google Maps V3 API Key Invalid - but my personal dev key works

后端 未结 11 895
梦谈多话
梦谈多话 2020-12-31 10:24

I\'ve recently been doing development upgrading our maps to v3 and during development I was using my own personal key. Everything was working fine. When it was time to go to

相关标签:
11条回答
  • 2020-12-31 10:53

    If you are testing locally, make sure to add your local ip to the server key:

    xxx.xxx.xxx.xxx
    

    if you want the maps api to be available across the whole domain add this to the browser key:

    *.mydomain.com/*
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-31 10:55

    I had a number of reports from clients about problems with Google maps on their sites. I checked and got "Invalid key" errors.

    Strangely, Google used to give out keys with a space before and after the API key. In the past, when I left the spaces off, the key broke. It was frustrating to remember to leave those spaces.

    Now, I trim() my current API Key (with or without spaces) before submitting it to Google Maps and it works.

    0 讨论(0)
  • 2020-12-31 10:55

    Now adding a map from Google has become more problematic than it was before. On the page https://leafletjs.com/ you will find another more convenient library with maps.

    0 讨论(0)
  • 2020-12-31 10:56

    Add v=3; before your key.

    maps.googleapis.com/maps/api/js?**v=3;**key={your key};sensor=false
    
    0 讨论(0)
  • 2020-12-31 10:57

    I think you must check the referrers. The given example on the API console site is:

    Example: *.example.com/*. *One URL or pattern per line.*
    

    Try to include the full referrer names without using wildcards. The wildcard usage seems a bit strange. More people struggle with that, see this post. You can find a description of the possible whitelist configuration on the Google APIs Console Help page.

    (You mentioned that your personal key has the same referrers as your company key. I wonder if this is possible as you could use different keys for the same app in this case.)

    0 讨论(0)
  • 2020-12-31 10:59

    I was able to resolve this issue by simply generating a new browser key. I generated, threw it in the browser, the map loaded. Then I went in and copied my referrers over from the previous key. Saved. Refreshed. And it still worked. I honestly think it was a bug on Google's end and the day we were generating the original keys it was spitting out invalid keys.

    0 讨论(0)
提交回复
热议问题