Goofy
Goofy

Reputation: 230

Google Static map without api key gives 403(forbidden) error

I am creating pdf document using jspdf. In the document i have to display google map, so i used static google maps https://developers.google.com/maps/documentation/static-maps/intro. This works fine on localhost.

But on deploying the app it gives error 403(forbidden) i also added parameter sensor=false in static map url.

Request URL : 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

Thanks.

Upvotes: 0

Views: 3192

Answers (1)

lukaleli
lukaleli

Reputation: 3625

Because you MUST include API key in your request as a parameter. Without it you don't have an access to the Google Maps API thus 403 error code which clearly states: access is forbidden. You even provided a documentation which shows an example of the request:

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

The last key parameter is required to make it working.

Upvotes: 3

Related Questions