Search code examples
google-mapsgoogle-maps-static-api

Google Maps Static API always shows broken link. What am I doing wrong?


I want to set a basic static map image on my site and so want to use the Google Maps Static API.

I've followed the documentation here: https://developers.google.com/maps/documentation/maps-static/dev-guide

And have built an image link as such:

<img src="https://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&amp;zoom=14&amp;size=400x400&amp;key=ABC123">

But it doesn't work - all I see is a broken image. I've tried several of my API keys, but with no luck.

Is there something I am missing? Some other parameter I need?


Solution

  • Remove the HTML encoding from the URL (&amp; should be &). This works for me:

    <img src="https://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400" />
    

    working image