Hi,
I'm trying to refresh a featureLayer in Esri Leaflet 3.0.3 (but this also happens in previous versions) that calls an AGOL FeatureServer service, with the refresh() method and setInterval, but it does not work as expected.
The implementation is very simple:
var testIcons = {
'A': L.icon({
iconUrl: 'A.png',
iconSize: [35, 35],
iconAnchor: [6, 6],
popupAnchor: [-3, -5],
}),
'B': L.icon({
iconUrl: 'B.png',
iconSize: [35, 35],
iconAnchor: [6, 6],
popupAnchor: [-3, -5],
}),
};
var testLayer = L.esri.featureLayer({
url: 'https://services5.arcgis.com/xyz/ArcGIS/rest/services/NAME/FeatureServer/0',
pointToLayer: function (geojson, latlng) {
return L.marker(latlng, {
icon: testIcons[geojson.properties.Status]
});
}
}).addTo(map);
testLayer.bindPopup(function (layer) {
return L.Util.template('<b>Name:</b> {Name}</br><b>Status:</b> {Status}', layer.feature.properties);
});
setInterval(function() {
testLayer.refresh();
}, 120000);//2min
Looking at the browser console, the layer refreshes at the given interval, but it loads the same data again. Sometimes, after a long period with the same data on map, it changes, but very outdated when compared with the service.
I've some other layers working fine and configured exactly the same way, but they are MapServer services.
So, my question is, refresh() method does not work well with FeatureServer services in featureLayers? The implementation needs to be different than with MapServer services? Or this should work and it can be a bug?
Thank you very much!