title: Google Map API marker update from JS
body: <p>I would like to ask you a solution for this problem.
  I have a JS with a variable inside that is updated overtime by a JAVA application (i.e. JAVA writer into a thread), after that I take the coordinates from that variable and I create a new object Marker for my google maps. <strong>The problem is that the marker does not changes position, it changes only if I refresh the whole page (I dont want to do this).</strong></p>
  
  <p>Here's the code to be more clear. 
  The inputData.js where the variable is written by the java application</p>
  
  <pre><code>var newMarker = {'latitude':38.25705300000004,'longitude': 140.83760400000006};
  </code></pre>
  
  <p>my html page used to display the map</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;Simple markers&lt;/title&gt;
          &lt;style&gt;
              html, body, #map-canvas {
                  height: 100%;
                  margin: 0px;
                  padding: 0px
              }
          &lt;/style&gt;
          &lt;script type="text/javascript"
                  src="https://maps.googleapis.com/maps/api/js?key=MYKEY"&gt;
          &lt;/script&gt;   
          &lt;script type="text/javascript" src="inputData.js"&gt;&lt;/script&gt;
          &lt;script&gt;
                      var map;
                      var sendai = new google.maps.LatLng(38.259535, 140.846816);
                      var lastPosition;
                      var image = 'images/circle-16.png';
  
                      function initialize() {
                          var mapOptions = {
                              zoom: 12,
                              center: sendai,
                              mapTypeId: google.maps.MapTypeId.ROADMAP};
  
                          map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
                      }
  
                      setInterval(refreshData, 2000);
  
                      function refreshData() {
                          var marker = new google.maps.Marker({
                              map: map,
                              icon: image,
                              draggable: false
                          });
                          marker.setPosition(new google.maps.LatLng(newMarker.latitude, newMarker.longitude));
                          map.setCenter(new google.maps.LatLng(newMarker.latitude, newMarker.longitude));
                          map.setZoom(18);
                      }
  
                      google.maps.event.addDomListener(window, 'load', initialize);
  
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="map-canvas"&gt;&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If I open my page like this everything work but when I change the script "inputData.js" the marker does not changes position.
  The method setCenter on the other hand seems to work properly.</p>
  
  <p>Help me please!</p>