[英]Google Static map without api key gives 403(forbidden) error
我正在使用jspdf創建pdf文檔。 在文檔中,我必須顯示Google Map,因此我使用了靜態Google Maps https://developers.google.com/maps/documentation/static-maps/intro 。 這在localhost上工作正常。
但是在部署應用程序時,它給出了錯誤403(禁止),我還在靜態地圖網址中添加了參數sensor = false。
請求網址 : https://maps.googleapis.com/maps/api/staticmap?center=47.3857009,9.2798472&zoom=15&scale=2&format=png&size=600x400&maptype=roadMap&sensor=false&markers=size:mid%7Ccolor:0xff0000%7C47.3857009,9.2798472
: https://maps.googleapis.com/maps/api/staticmap?center=47.3857009,9.2798472&zoom=15&scale=2&format=png&size=600x400&maptype=roadMap&sensor=false&markers=size:mid%7Ccolor:0xff0000%7C47.3857009,9.2798472
size : https://maps.googleapis.com/maps/api/staticmap?center=47.3857009,9.2798472&zoom=15&scale=2&format=png&size=600x400&maptype=roadMap&sensor=false&markers=size:mid%7Ccolor:0xff0000%7C47.3857009,9.2798472
7Ccolor : https://maps.googleapis.com/maps/api/staticmap?center=47.3857009,9.2798472&zoom=15&scale=2&format=png&size=600x400&maptype=roadMap&sensor=false&markers=size:mid%7Ccolor:0xff0000%7C47.3857009,9.2798472
謝謝。
因為您必須在請求中包含API密鑰作為參數。 沒有它,您將無權訪問Google Maps API,因此會出現403
錯誤代碼,其中清楚指出:禁止訪問。 您甚至提供了一個文檔,其中顯示了請求的示例:
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap
&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
&markers=color:red%7Clabel:C%7C40.718217,-73.998284
&key=YOUR_API_KEY
必須使用最后一個key
參數才能使其正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.