Hi I need someone that can help me with a Wordpress theme that incorporates Google Map. Problem is the Google Map keeps calling up cities in the United States that have the same name as cities in the country that I am building this site for. Can someone please help me edit this code so that I can be able to enter the country that I want the Google Map to display. Here is the code: <?php //Google Maps - Initiating Variable $address = get_post_meta($post->ID, 'address', true); $city = get_post_meta($post->ID, 'city', true); $state = get_post_meta($post->ID, 'state', true); $zip = get_post_meta($post->ID, 'zip', true); $image1 = get_post_meta($post->ID, 'red_image1', true); for($i = 1; $i <= 1; $i++) {$image = get_post_meta($post->ID, "red_image".$i, true); $blogurl = get_bloginfo('template_url'); if($image){ $output = $blogurl.'/thumbnail.php?src='.$image.'&h=60&w=85&zc=1'; } } ?> <!--[if lt IE 7]> <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"> </script> <![endif]--> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var mapOptions = { googleBarOptions : { style : "new" } } var map = new GMap2(document.getElementById("map"),mapOptions); var geocoder = new GClientGeocoder(); map.setUIToDefault(); map.enableGoogleBar(); showaddress(map, geocoder, "<?=$address?> <?=$city?>"); } } function showaddress(map, geocoder, address) { geocoder.getLatLng( address, function(latlng) { if (!latlng) { alert(address + " not found"); } else { map.setCenter(latlng, 16); var marker = new GMarker(latlng); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml("<table width='215' height='50'><tr><td><img style='border:2px solid #ccc;color:#000;' src='<?php echo $output ?>'/></td></tr><tr><td><?php echo $address?> <?php echo $city?> <?php echo $state ?></td></tr></table><br /><a target='_blank' href='http://maps.google.com/maps?q=<?php echo $address?>, <?php echo $city?>, <?php echo $state ?>'>Directions</a>"); }); map.addOverlay(marker); map.disableScrollWheelZoom(); } } ); } //]]> </script> Code (markup):
Hi there, Try this: <?php //Google Maps - Initiating Variable $address = get_post_meta($post->ID, 'address', true); $city = get_post_meta($post->ID, 'city', true); $country = get_post_meta($post->ID, 'country', true); $state = get_post_meta($post->ID, 'state', true); $zip = get_post_meta($post->ID, 'zip', true); $image1 = get_post_meta($post->ID, 'red_image1', true); for($i = 1; $i <= 1; $i++) {$image = get_post_meta($post->ID, "red_image".$i, true); $blogurl = get_bloginfo('template_url'); if($image){ $output = $blogurl.'/thumbnail.php?src='.$image.'&h=60&w=85&zc=1'; } } ?> <!--[if lt IE 7]> <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"> </script> <![endif]--> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var mapOptions = { googleBarOptions : { style : "new" } } var map = new GMap2(document.getElementById("map"),mapOptions); var geocoder = new GClientGeocoder(); map.setUIToDefault(); map.enableGoogleBar(); showaddress(map, geocoder, "<?=$address?> <?=$city?> <?=$country?>"); } } function showaddress(map, geocoder, address) { geocoder.getLatLng( address, function(latlng) { if (!latlng) { alert(address + " not found"); } else { map.setCenter(latlng, 16); var marker = new GMarker(latlng); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml("<table width='215' height='50'><tr><td><img style='border:2px solid #ccc;color:#000;' src='<?php echo $output ?>'/></td></tr><tr><td><?php echo $address?> <?php echo $city?> <?php echo $state ?> <?pho echo $country; ?></td></tr></table><br /><a target='_blank' href='http://maps.google.com/maps?q=<?php echo $address?>, <?php echo $city?>, <?php echo $state ?>, <?php echo $country; ?>'>Directions</a>"); }); map.addOverlay(marker); map.disableScrollWheelZoom(); } } ); } //]]> </script> Code (markup):
Thanks for trying but I am getting this error now: Parse error: syntax error, unexpected T_ECHO **********maps.php on line 49 Any other ideas?
Oops, typo. Try this instead: <?php //Google Maps - Initiating Variable $address = get_post_meta($post->ID, 'address', true); $city = get_post_meta($post->ID, 'city', true); $country = get_post_meta($post->ID, 'country', true); $state = get_post_meta($post->ID, 'state', true); $zip = get_post_meta($post->ID, 'zip', true); $image1 = get_post_meta($post->ID, 'red_image1', true); for($i = 1; $i <= 1; $i++) {$image = get_post_meta($post->ID, "red_image".$i, true); $blogurl = get_bloginfo('template_url'); if($image){ $output = $blogurl.'/thumbnail.php?src='.$image.'&h=60&w=85&zc=1'; } } ?> <!--[if lt IE 7]> <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"> </script> <![endif]--> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var mapOptions = { googleBarOptions : { style : "new" } } var map = new GMap2(document.getElementById("map"),mapOptions); var geocoder = new GClientGeocoder(); map.setUIToDefault(); map.enableGoogleBar(); showaddress(map, geocoder, "<?=$address?> <?=$city?> <?=$country?>"); } } function showaddress(map, geocoder, address) { geocoder.getLatLng( address, function(latlng) { if (!latlng) { alert(address + " not found"); } else { map.setCenter(latlng, 16); var marker = new GMarker(latlng); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml("<table width='215' height='50'><tr><td><img style='border:2px solid #ccc;color:#000;' src='<?php echo $output ?>'/></td></tr><tr><td><?php echo $address?> <?php echo $city?> <?php echo $state ?> <?php echo $country ?></td></tr></table><br /><a target='_blank' href='http://maps.google.com/maps?q=<?php echo $address?>, <?php echo $city?>, <?php echo $state ?>, <?php echo $country ?>'>Directions</a>"); }); map.addOverlay(marker); map.disableScrollWheelZoom(); } } ); } //]]> </script> Code (markup):