Google static map API getting 403 forbidden when loading from img tag

后端 未结 11 885
执念已碎
执念已碎 2021-01-03 21:15

What I have is a Google map that shows the location of a property but when I come to print the dynamic maps dont print so good so I decided to implement the Google Static Ma

11条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 21:43

    This has gotten quite a lot of views, so I'm adding my solution to the problem here:

    When using the new API, make sure you generate a Key for browser apps (with referers) and also make sure the patterns match your URL.

    E.g. when requesting from example.com your pattern should be

      example.com/*
    

    When you're requesting from www.example.com:

      *.example.com/*
    

    So make sure you check whether a subdomain is present and allow both patterns in the developer console.

    1. Visit the Developer Console.
    2. Under API Keys, click the pencil icon to edit.
    3. Under "Key restrictions", ensure that you have an entry for example.com/*, *.example.com/*, and any local testing domains you might want.

提交回复
热议问题