Here’s a simple way to add Google Maps to Instant Curator, enabling you to show a map via a simple shortcode in your WordPress posts.
1. URL Format
First we need to find the URL format for Google Maps. The idea is that we will simply pass parameters to this URL and iframe the resulting map.
The URL format for Google Maps looks like this:
Here are some notes on these Google Maps parameters:
- q=ADDRESS,CITY,STATE+ZIP – a zip code will help pinpoint the location, but most times you aren’t going to know the zip code so we’ll leave it out. You could also use latitude and longitude (in decimal form or as degrees, minutes and seconds) as well as landmarks.
- Values for zoomlevel (the z option): 1-19
- Values for LANGUAGE (the hl option): en, fr, de, etc.
- TEXT_IN_BUBBLE means we can put whatever we want the location text to be here.
- iwloc can hide the text bubble completely by setting the variable to “near” (default is “addr”, which places the bubble pointing to a set address). Other values include: A-J (to associate the bubble with a business marker) and “start,end” for driving directions.
- mrt is locations that the map returns. Default value is blank, which searches for everything (equivalent to specifying the “all” option). Other options are:
- mrt=yp – Yellow pages search (searches nearby businesses)
- mrt=realestate — real estate listings
- mrt=ds — Related maps
- mrt=websearch — searches webpages in Google for the given geographical position.
- mrt=loc — Locations search.
- mrt=kmlkmz – searches the community maps.
- t=“m” is Map Type. The available options are “m” map, “k” satellite, “h” hybrid, “p” terrain.
More description on the available Google Maps parameters are available here.
Note that you can also create static, non-interactive Google Maps using the following link format:
You can get more information on Google Static Maps from here:
2. Create Shortcode & Parameters for Google Maps
I’m going to call this shortcode google_maps – the plugin sticks an ic_ in front of every shortcode it installs, so as long as I’m not using a Google Maps plugin, I know there won’t be any naming conflicts. Add the following attributes to the shortcode:
This gives three variables that can be set inside the shortcode:
- Location, most likely city, state (or address, city, state). Since this is a map plugin, this variable is required.
- Bubbletext – optional text to explain map location.
- Country – default will be set to ‘us’, but can be changed to whatever default locale is most useful for you.
3. Insert the template tokens into the iframe
We grab the template tokens by hitting the ‘Get Tokens’ button:
And we just drag those tokens where we want them into our constructed Google Maps URL that we iframe:
<iframe width="460" height="415" src="http://maps.google.com/maps?q=%location%,+%country%(%bubbletext%)&output=embed &t=h&z=14&hl=en&iwloc=addr&t=m"></iframe>
4. Insert the shortcode into posts
Here’s the shortcode and the map it produces:
If you don’t have Instant Curator or want to add Google Maps through another plugin, then you’ll find plenty of options here: http://wpguidance.com/479/google-maps-themes-and-plugins-for-wordpress/.