Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter justin_h

    (@justin_h)

    Hello again, I have managed to solve this!

    No plugins needed, I just attached the standard javascript code in my header.php and then went on to add this to my sidebar-page.php:

    <body onunload="GUnload()"> 
    
        <div id="map_canvas" style="width: 250px; height: 250px"></div> 
    
        <script type="text/javascript"> 
    
        var yourAddress = '<?php echo stripslashes($options['address_country']);  ?>';
    
        if (GBrowserIsCompatible()) {
           var geocoder = new GClientGeocoder();
           geocoder.getLocations(yourAddress, function (locations) {
              if (locations.Placemark)
              {
                 var north = locations.Placemark[0].ExtendedData.LatLonBox.north;
                 var south = locations.Placemark[0].ExtendedData.LatLonBox.south;
                 var east  = locations.Placemark[0].ExtendedData.LatLonBox.east;
                 var west  = locations.Placemark[0].ExtendedData.LatLonBox.west;
    
                 var bounds = new GLatLngBounds(new GLatLng(south, west),
                                                new GLatLng(north, east));
    
                 var map = new GMap2(document.getElementById("map_canvas"));
    
                 map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
              }
           });
        }
        </script>
      </body>

    More info can be found here: http://stackoverflow.com/questions/2297486/render-google-map-in-wordpress-based-on-address-custom-field

Viewing 1 replies (of 1 total)