![](https://stoock.xyz/wp-content/uploads/2019/11/7844cb642656ad1ee58d388bf2f4f548.png)
Advanced Custom Fieldsをインストール後、Googleマップ機能を使おうとすると「 このページではGoogleマップが正しく読み込まれませんでした。 」とエラーが表示されて使えません。
解決方法は公式ドキュメント通りで、Google Cloud Platformでプロジェクトを作成し、APIキーを取得します。取得したAPIキーを functions.phpに記述。そして、3つのAPIを有効化することで正常に利用ができるようになります。
Google Cloud PlatformのAPIキーを取得
![](https://stoock.xyz/wp-content/uploads/2019/11/29ef473bd1888dbac0f282022dd8b0ad.png)
Google Cloud Platformでプロジェクトを作成し、認証情報を作成してAPIキーを取得します。
APIキーをfunctions.phpに設定
wordpressのfunctions.phpに以下の記述を追加します。
function my_acf_google_map_api( $api ){ $api['key'] = 'ここにAPIキーが入ります'; return $api; } add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');
APIを有効化する
![](https://stoock.xyz/wp-content/uploads/2019/11/65c477feaebf28a88a6f01512a91cfc3.png)
![](https://stoock.xyz/wp-content/uploads/2019/11/5592a90a4d05a8c4944e3ed0a99d624d.png)
Advanced Custom Fieldsで使用されているGoogle Cloud PlatformのAPIライブラリ「Maps JavaScript API」「Geocoding API」「Places API」を有効化します。
Maps Embed APIは有効化しなくても良さそうですが、念のため。
管理画面のAPIエラーが解消
![](https://stoock.xyz/wp-content/uploads/2019/11/55e7204c1fafa671824b31ba69b39524.png)
上項の設定が反映されるまで少しタイムラグがあるかもしれません。
地図をiframeタグで表示する
iframeタグでhtmlに埋め込む場合は以下で表示できます。
![](https://stoock.xyz/wp-content/uploads/2019/11/8b8b55bb9a87de15814e68085e8337a5.png)