「This site can’t load Google Maps correctly. Do you own this website? g.co/staticmaperror/key」と表示される場合

「This site can’t load Google Maps correctly. Do you own this website? g.co/staticmaperror/key」と表示される場合

Google MapのMaps Static APIがリンク切れになって、画像のURLを開くとグレーの背景に「This site can’t load Google Maps correctly. Do you own this website? g.co/staticmaperror/key」と表示される場合、それは、APIキーが設定されていないためにエラーになってしまっている合図です。

それを直すためには、Google Maps Platformに登録を行い、そこでAPIキーを発行しなくてはいけません。

APIキーを発行したら、今までのURLに「&key=APIキー」を追加してあげることで今まで通り正常にGoogle Mapが表示することができます。

サンプルURL

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