Buying Google Map Help

Discussion in 'Programming' started by smartalex4, Jan 24, 2011.

  1. #1
    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):
     
    smartalex4, Jan 24, 2011 IP
  2. austin-G

    austin-G Peon

    Messages:
    435
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    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):
     
    austin-G, Jan 24, 2011 IP
  3. smartalex4

    smartalex4 Active Member

    Messages:
    264
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    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?
     
    smartalex4, Jan 24, 2011 IP
  4. mr.manan

    mr.manan Active Member

    Messages:
    268
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    I suppose you need google API key for displaying users country on the map.
     
    mr.manan, Jan 24, 2011 IP
  5. smartalex4

    smartalex4 Active Member

    Messages:
    264
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    I have a Google API key....are there country specific API Keys?
     
    smartalex4, Jan 24, 2011 IP
  6. mr.manan

    mr.manan Active Member

    Messages:
    268
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    No keys are not country specific. It auto fetch data from profile/fields/variable.
     
    mr.manan, Jan 24, 2011 IP
  7. austin-G

    austin-G Peon

    Messages:
    435
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    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):
     
    austin-G, Jan 24, 2011 IP