title: How to update leaflet markers for every 5 seconds
body: <p>I am working on a Leaflet map and markers.</p>
  
  <p>I am getting markers latlng from JSON and showing it correctly.</p>
  
  <pre><code>getLatLng()
  
  function getLatLng() {
    var details = '/equipment/api/getLatLong';
    $.ajax({
      url: details,
      method: 'get'
    }).done(function(response) {
  
      $('.subSection').html('').append('&lt;section&gt;&lt;button type="button" onclick="hideEquipmentDetails()"&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/section&gt;');
      var equipmentDetails = response.data.filters;
      console.log(equipmentDetails)
      $.each(equipmentDetails, function(i, value) {
        L.marker([value.latitude, value.longitude]).addTo(map).bindPopup('&lt;b&gt;&lt;span&gt; Name:&lt;/span&gt;' + value.name + '&lt;/b&gt;');
      })
    });
  }
  
  setInterval(function() {
    getLatLng();
  }, 5000)
  </code></pre>
  
  <p>I am refreshing the method for every 5 seconds.</p>
  
  <p>So I need to show the markers in updated latlng and old markers should be hidden.</p>
  
  <pre><code>setInterval(function() {
    //L.marker.setOpacity(0);
    //L.markerClusterGroup()
    //markers.clearLayers();
    //map.removeLayer(L.marker);
    //markers.removeLayer()
    //L.marker().removeTo(map);
    getLatLng();
  }, 5000)
  </code></pre>
  
  <p>I tried every options to achieve this but I couldn't.</p>
  
  <p>Is there any other way to do it?</p>
  
  <p>Otherwise should I define one more array to store the initial latlng values then to check each time whether latlng is changed or not (in this scenario I can replace only updated latlng markers right?No need to replace all markers every time right?)</p>