title: how to refresh content of already open infowindow of google maps when marker position is refreshed?
body: <p>I have a google map and markers on it. Markers can move like vehicle tracking.I succeeded moving the markers according to new location data.There is no problem here.When clicking a marker, a infowindow which has location info (lng &amp; ltd) is opened.But If marker move another location while infowindow is open, content(location info) of infowindow dont change. </p>
  
  <p>How to change infowindow's content with new location info while marker moves?</p>
  
  <p>Please help me to overcome the problem?</p>
  
  <p><strong>creating markers firstly is as follows;</strong></p>
  
  <pre><code> var mapOptions = {
          zoom: 10,
          center: new google.maps.LatLng(37.2312, 36.9041),
          mapTypeId: google.maps.MapTypeId.SATELLITE,
          disableDefaultUI: false,
          zoomControl: true
      };
   var map = new google.maps.Map(document.getElementById('pnlMap'), mapOptions);
   var latlng = new google.maps.LatLng(coordinateInfo[1].replace(',', '.'), coordinateInfo[0].replace(',', '.'));
                      bounds.extend(latlng);
  
                      var marker = new google.maps.Marker({
                          position: latlng,
                          map: map,
                          icon: '../images/ship_icon.png',
                          store_id: coordinateInfo[3],
                          title: coordinateInfo[2]
                      });
                      markerList.push(marker);
  
                      (function (marker, coordinateInfo) {
                          google.maps.event.addListener(marker, "click", function (e) {
                              infoWindow.setContent(
                          '&lt;div id="iw-container"&gt;' +
                              '&lt;div class="iw-title"&gt;' + coordinateInfo[2] +
                                  '&lt;div class="iw-content"&gt;' +
                          '&lt;table class="zebra"&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Gemi Adı : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[2] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Cihaz ID Numarası : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[3] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Koordinat Bilgileri(X,Y) : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[0] + ' - ' + coordinateInfo[1] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Telefon Numarası : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[9] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Telsiz Numarası : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Hız : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[6] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Gps Zamanı : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[10] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Konum : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfo[11] + '&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;' +
                              '&lt;/div&gt;' +
                          '&lt;/div&gt;');
                              infoWindow.maxWidth = 380;
                              infoWindow.maxWidth = 380;
                              infoWindow.open(map, marker);
                          });
                      })(marker, coordinateInfo);
  
                      google.maps.event.addListener(map, 'click', function () {
                          infoWindow.close();
                      });
  </code></pre>
  
  <p><strong>updating markers' new position is as follows;</strong></p>
  
  <pre><code>  for (var k = 0; k &lt; coordinateLength - 1; k++) {
                      var coordinateInfoTemp = coordinates[k].split("~");
                      for (var j = 0; j &lt; markerList.length; j++) {
                          var markerTmp = markerList[j];
                          if (markerTmp.store_id === coordinateInfoTemp[3]) {
                              var latlngNew = new google.maps.LatLng(coordinateInfoTemp[1].replace(',', '.'), coordinateInfoTemp[0].replace(',', '.'));
                              markerTmp.setPosition(latlngNew);
                              (function (markerTmp, coordinateInfoTemp) {
                                  google.maps.event.addListener(markerTmp, "click", function (e) {
                                      alert(coordinateInfoTemp[10]);
                                      infoWindow.setContent(
                                                              '&lt;div id="iw-container"&gt;' +
                                                                  '&lt;div class="iw-title"&gt;' + coordinateInfoTemp[2] +
                                                                      '&lt;div class="iw-content"&gt;' +
                                                              '&lt;table class="zebra"&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Gemi Adı : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfoTemp[2] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Cihaz ID Numarası : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfoTemp[3] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Koordinat Bilgileri : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfoTemp[0] + ' - ' + coordinateInfoTemp[1] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Telefon Numarası : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfoTemp[9] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Telsiz Numarası : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Hız : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfoTemp[6] + '&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Gps Zamanı : &lt;/b&gt;&lt;/td&gt; &lt;td&gt;' + coordinateInfoTemp[10] + '&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;' +
                                                                  '&lt;/div&gt;' +
                                                              '&lt;/div&gt;');
                                      infoWindow.maxWidth = 380;
                                      infoWindow.refresh();
                                  });
                              })(markerTmp, coordinateInfoTemp);
                              break;
                          }
                      }
                  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I found the solution by adding following control, when I clicked a marker I am setting markerTmp.store_id to selectedMarkerStoreId variable;</p>
  
  <pre><code>if (selectedMarkerStoreId != null &amp;&amp; selectedMarkerStoreId === markerTmp.store_id) {
                                      infoWindow.setContent(markerTmp.htmlContent);
                                  }
  </code></pre>