title: Google Maps API v3 - How to update the InfoWindow of a Marker
body: <p>Is it possible to target a specific Marker's InfoWindow to update it?</p>
  
  <p>When a Marker is clicked, it opens the InfoWindow showing name and address. It also sends the Lat and Long to a PHP script to bring back more details about this Marker from the database in a div off the map.</p>
  
  <p>I would like to be able to update the name and address using this off-map div, which is no problem - I am stuck on how to target that particular Marker's InfoWindow to update it with the new name and address though.</p>
  
  <p>I've added an id to each Marker, but I'm not sure how to use it (or if it's possible) to target the Marker with that id and update its InfoWindow from my other function that sends the info to the database.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>     var map;
       var map_center = {lat: &lt;?=$map['lat']?&gt;, lng: &lt;?=$map['lng']?&gt;};
       var markers = [];
       var infowindow = new google.maps.InfoWindow();
  
       map_initialize(); // initialize google map
       
       //############### Google Map Initialize ##############
       function map_initialize() {
          var googleMapOptions = { 
            center: map_center, // map center
            zoom: 15, //zoom level, 0 = earth view to higher value
            panControl: true, //enable pan Control
            zoomControl: true, //enable zoom control
            zoomControlOptions: {
            style: google.maps.ZoomControlStyle.SMALL //zoom control size
          },
           scaleControl: true, // enable scale control
            mapTypeId: google.maps.MapTypeId.ROADMAP // google map type
          };
      
          map = new google.maps.Map(document.getElementById("map"), googleMapOptions);         
          
          $.getJSON("&lt;?=$urlpath?&gt;map_process.php", function(data) {
           
         $.each(data, function(key, val) {
        var point      = new google.maps.LatLng(parseFloat(val['lat']),parseFloat(val['lng']));
        var name       = val['name'];
        var address    = '&lt;p&gt;'+ val['address'] +'&lt;/p&gt;';
        var properties = val['properties'];
       var id     = val['id'];
       
       create_marker(point, name, address, false, false, "/images/pin_green.png", properties, id);
        })
     });
                              
      }
  
    //############### Function create_marker ##############
    
    
    function create_marker(MapPos, MapTitle, MapDesc, InfoOpenDefault, DragAble, iconPath, properties, id) {           
       
       var this_id = 'marker_' + id;
        
        //new marker
        var marker = new google.maps.Marker({
         id: this_id,
           position: MapPos,
           map: map,
           draggable: DragAble,
           animation: google.maps.Animation.DROP,
           title: MapTitle,
           icon: iconPath,
           properties: properties
        });
        
        //Content structure of info Window for the Markers
        var contentString = $('&lt;div class="marker-info-win"&gt;'+
        '&lt;div class="marker-inner-win"&gt;&lt;span class="info-content"&gt;'+
        '&lt;h1 class="marker-heading"&gt;'+MapTitle+'&lt;/h1&gt;'+
        MapDesc+ 
        '&lt;/span&gt;'+
        '&lt;/div&gt;&lt;/div&gt;');    
  
       google.maps.event.addListener(marker, 'click', function(event) {
  
         infowindow.setContent(contentString[0]);
         infowindow.open(map, marker);
         
         //############### Send latlng to right panel ##############
         
         var mLatLang = marker.getPosition().toUrlValue(); //get marker position
         showRightPanel(mLatLang);
         
       });
            
      markers.push(marker);
     }  
  
  
  
  
     function showRightPanel(mLatLang) { //function that will add markers on button click
     
         var myData = {latlang : mLatLang}; //post variables
         $.ajax({
           type: "POST",
           url: "&lt;?=$urlpath?&gt;map_show_panel.php",
           data: myData,
           success:function(data){
            $('#marker_result').html(data);
           },
           error:function (xhr, ajaxOptions, thrownError){
            alert(thrownError); //throw any errors
           }
         });
     
     }</code></pre>
  </div>
  </div>
  </p>