Google Maps Sidebar Widget for WordPress (Per Post)

My friends at Moss Creek Media had an idea. They wanted to put a Google map of where a picture was taken next to the image.
I looked at all the plug ins and could only find one that added a Google map to a sidebar. This was great! Something existed so I didn't have to build it but, it only supported one location (defined globally for every instance of the widget) and what I needed to do was set the location according to the currently displayed image.
Modification time
The original plug-in google-map-v3-for-idn created by Raphael Berrhoun was very easy to modify. I created a new shortcode called gps that you insert into each post where the sidebar widget is displayed.
[gps latitude="43.62132" longitude="-71.629517" description="<strong>House of Goodness</strong><br/>31 Main St<br/>Oakland, CA 12334"]
Next all I had to do was modify some of the javascript to read the values passed in by the shortcode (should they be available). If the values were not present then it defaults to the normal values.
function makeMap() {
var lat = '".$lat."';
var lng = '".$lng."';
var info ='';
if ( (document.getElementById('gps-latitude')!='undefined') && (document.getElementById('lng')!='undefined') ) {
lat = document.getElementById('gps-latitude').innerHTML;
lng = document.getElementById('gps-longitude').innerHTML;
info = document.getElementById('gps-description').innerHTML;
}
Usage
You can download my modified the version of the plug-in. All that you will need to do is add the GPS line to your post and make sure you have installed the widget into your sidebar and populated the Google Maps API key. (Under settings in the control panel)
mod_google-map-v3-for-idn.zip (14.3 KiB, 122 hits)








