How To: Auto-refresh a feature layer periodically using the ArcGIS API for JavaScript


The base class for all layers in ArcGIS API for JavaScript 3.x provides a 'refreshInterval' property, which allows the layer to automatically refresh at the set interval. 

The following instructions describe how to auto-refresh a feature layer periodically using ArcGIS API for JavaScript 3.20. All classes that inherit from the base class Layer have access to the refreshInterval property and the setRefreshInterval() method. Hence, the refresh interval can be set on a graphics layer and a dynamic map service layer the same way.


There are two ways of setting the feature layer's refresh interval:

  • The first option is to set the refresh interval property on a feature layer by calling the setRefreshInterval(interval) method using the following script:
var featureLayer = new
featureLayer.setRefreshInterval(1); //Set the interval to 1 minute
    • The second option is to set the refreshInterval property when instantiating a feature layer by applying the property in the layer object using the following script:
    var featureLayer = new FeatureLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0", {
       mode: FeatureLayer.MODE_ONDEMAND,
       refreshInterval: 1, //Set the interval to 1 minute
    The refreshInterval property enables a timer for the set interval and the client requests new features based on the used to add the feature layer.

    For more information on the setRefreshInterval(interval) method and refreshInterval property, refer to the following web help documents:

    Related Information