title: refreshing marker position every 5 seconds in google maps JavaScript API
body: <pre><code>      setInterval(function () {initMap();},5000);
         //setInterval(function () {changeMarkerPosition(marker);},5000);
            var map;
  
            function initMap() {
              var lat = document.getElementById( 'lat' ).value;
              var lng = document.getElementById( 'lng' ).value;
  
              map = new google.maps.Map(
                  document.getElementById('map'),
                  {center: new google.maps.LatLng(lat, lng), zoom: 16});
  
              var iconBase =
                  'https://developers.google.com/maps/documentation/javascript/examples/full/images/';
  
              var icons = {
                parking: {
                  icon: iconBase + 'parking_lot_maps.png'
                },
                library: {
                  icon: iconBase + 'library_maps.png'
                },
                info: {
                  icon: iconBase + 'info-i_maps.png'
                }
              };
  
              var features = [
                {
                  position: new google.maps.LatLng(lat, lng),
                  type: 'info'
                },
              ];
  
              // Create markers in the map.
              for (var i = 0; i &lt; features.length; i++) {
                var marker = new google.maps.Marker({
                  position: features[i].position,
                  icon: icons[features[i].type].icon,
                  map: map
                });
              };
            }
  </code></pre>
  
  <p>This is my code which refreshes the whole map every 5 seconds instead i want to refresh the marker position every 5 seconds  as i am getting the latitude and longitude from two input fields which are updating continuously</p>