プラグインを使わずに、しかもGoogle Maps API Keyを取得せずにWordPressにGoogleMap
ワードプレスでグーグルマップを挿入し、表示させるには、もしかしたら表示させたい地図のアドレスを入れるだけで自動で表示してくれるかなーとか思っていたけども、そんなに甘くはありませんでした。orz
調べてみると、グーグルマップ表示用のプラグインはたくさんある。けれどもどれも“Google Maps API Keyを取得する必要がある”というものばかり。ちょっと億劫ですよねー。
でも、辿り着きました、iframeで表示させる方法。これならAPI Keyを取得しなくてもイインダヨー!
function.phpに
//Google Maps Shortcode function do_googleMaps($atts, $content = null) { extract(shortcode_atts(array( "width" => '640', "height" => '480', "src" => '' ), $atts)); return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed" ></iframe>'; } add_shortcode("googlemap", "do_googleMaps");
地図を表示させたいページに以下のコード
[googlemap width="横幅" height="縦幅" src="地図のURL"]
参考:
http://www.dekipaso.com/info/google-maps-without-plugin.html
http://wptricks.net/how-to-inserting-google-maps-into-wordpress/