Adding Google Maps to WordPress

February 23, 2010 6:14 pm Published by Leave your thoughts

In this brief tutorial Peak Studios Teaches you how to add Google Maps to you WordPress blog.

  • Copy the code below:

<script type=”text/javascript”
src=”;v=2&amp;key=GET YOUR GOOGLE API KEY”>
<script type=”text/javascript”>
function initialize() {
var mapCheck = document.getElementById(“map_canvas”);
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById(“map_canvas”));
var address = map_canvas.getAttribute(“address”);
var geocoder = new GClientGeocoder;
geocoder.getLatLng(address, function(point){
map.setCenter(point, 15, G_PHYSICAL_MAP);
var marker = new GMarker(point);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
</script>paste the code into the head of wp-content/theme/YOUR THEME/header.php

  • Copy and paste the code below in to any post you want a map on:

<div id=”map_canvas” style=”width:740px; height:300px;” address=”Boulder, CO”>You can change the size of the map and the location.
The address can go from exact to just the state or country.

You can add attributes in the div tag to do any thing you want just be sure to add the functionality to the java script.
Some great resources for learning more about the Google Maps API are:

Categorised in:

This post was written by admin

Leave a Reply