title: How to display location on markers of google maps when clicked?
body: <p>I have extracted the latitude and logitude from my database tables and have shown it on the google maps with markers.Now I want to get location to be displayed on the markers when they are clicked.I tried a lot but couldn't find the way.Can you please suggest how shall I proceeed?I am also giving the sample code which may help you.Kindly help me out.</p>
  
  <pre><code>&lt;?php
     $dbname='140dev';
     $dbuser='root';                              
      $dbpass='root';      
      $dbserver='localhost';
      $dbcnx = mysql_connect ("$dbserver", "$dbuser", "$dbpass");
         mysql_select_db("$dbname") or die(mysql_error());
  
  
  $sql = mysql_query("SELECT * FROM tweets1");
  $res =  mysql_fetch_array($sql);
  $lat_d = $res['geo_lat'];
  $long_d = $res['geo_long'];
  
  // mimic a result array from MySQL
  $result = array(array('geo_lat'=&gt;$lat_d,'geo_long'=&gt;$long_d));
  
  ?&gt;
  &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"
   src="http://maps.googleapis.com/maps/api/js?key="API_key"&amp;sensor=false"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      var map;
      function initialize() {
          // Set static latitude, longitude value
      var latlng = new google.maps.LatLng(&lt;?php echo $lat_d; ?&gt;, &lt;?php echo $long_d; ?&gt;);
          // Set map options
          var myOptions = {
              zoom: 16,
              center: latlng,
              panControl: true,
              zoomControl: true,
              scaleControl: true,
              mapTypeId: google.maps.MapTypeId.ROADMAP
          }
          // Create map object with options
          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      &lt;?php
          // uncomment the 2 lines below to get real data from the db
          $result = mysql_query("SELECT * FROM tweets1");
          while ($row = mysql_fetch_array($result))
  echo "addMarker(new google.maps.LatLng(".$row['geo_lat'].", ".$row['geo_long']."), 
  map);";
      ?&gt;
      }
  
  
      function addMarker(latLng, map) {
   var marker = new google.maps.Marker({
      position: latLng,
      map: map,
      draggable: true, // enables drag &amp; drop
      animation: google.maps.Animation.DROP
  });
  
  var contentString = latLng.lat() + " , " + latLng.lng();
  
  geocoder.geocode({'latLng': latlng}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    if (results[1]) {
      map.setZoom(11);
      marker = new google.maps.Marker({
          position: latlng,
          map: map
      });
      infowindow.setContent(results[1].formatted_address);
      infowindow.open(map, marker);
    } else {
      alert('No results found');
    }
   } else {
    alert('Geocoder failed due to: ' + status);
   }
   });
  
  google.maps.event.addListener(marker, 'click', function() {
     infowindow.open(map,marker);
   });
  }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="initialize()"&gt;
      &lt;div style="float:left; position:relative; width:550px; border:0px #000 solid;"&gt;
          &lt;div id="map_canvas" style="width:950px;height:700px;border:solid black 1px;"&gt;       
  &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>