• Okay, I searched all over for this and finally found something, however I am not sure what I am doing incorrectly, but it does not work on FF and IE but works on Chrome.

    1. Added the function below to my functions.php
    2. Called the function and pass an address (for testing I passed an address I know exists and as I said above it works on Chrome).

    Can anybody help ?

    function make_map($address)
    {
    
    	$google_api_key = '***'; // Starred out my API KEY
    
    	if($address): ?>
    	<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $google_api_key; ?>" type="text/javascript"></script>
    	<div id="map_canvas" style="width: 250px; height: 250px"></div>
    	<script type="text/javascript">
    
    	function showAddress(address)
    	{
    		var map = new GMap2(document.getElementById("map_canvas"));
    		var geocoder = new GClientGeocoder();
    		geocoder.getLatLng(
    			address,
    			function(point)
    			{
    				if (!point)
    				{
    				alert(address + " not found");
    				}
    				else
    				{
    				map.setCenter(point, 13);
    				var marker = new GMarker(point);
    				map.addOverlay(marker);
    				}
    			}
    		);
    	}
    	showAddress("<?php echo $address; ?>");
    	</script>
    	<br>
    	<?php endif;
    }
    add_action('before_post','make_map');
  • The topic ‘Generaet Google Map from an Address Custom Field’ is closed to new replies.