Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: CSVLayer

require(["esri/layers/CSVLayer"], function(CSVLayer) { /* code goes here */ });

Description

(Added at v3.9)
CSVLayer extends FeatureLayer to create a point layer based on a CSV file (.csv, .txt). CSV is a plain-text file format used to represent tabular data, including geographic point features (latitude, longitude). Features from the CSV file are accessible via the API so you can query features and use them as input to geometry or geoprocessing services.

Typically the latitude coordinate is the Y value, and the longitude coordinate is the X value.

If CSV files are not on the same domain as your website, a CORS enabled server or a proxy is required.

While extending the FeatureLayer class, CSVLayer behaves differently from FeatureLayer. It has the following behavior:
  • Edits are applied on the client not posted to the server.
  • The feature layer generates a unique object id for new features.
  • Does not support queries that need to be performed on the server, such as queries with a where clause or non-extent based spatial queries.
  • The feature layer toJson method returns an object with the same properties as the feature collection. The returned object includes all the features that are in the layer when the method is called. This method can be used to access a serializable representation of the features that can be saved on the server.

Samples

Search for samples that use this class.

Class hierarchy

esri/layers/Layer
|_esri/layers/GraphicsLayer
  |_esri/layers/FeatureLayer
    |_esri/layers/CSVLayer

Constructors

NameSummary
new CSVLayer(url, options?)Creates a CSV layer.

Properties

NameTypeSummary
advancedQueryCapabilitiesObjectAn object that contains service level metadata about whether or not the layer supports queries using statistics, order by fields, DISTINCT, pagination, query with distance, and returning queries with extents.
allowUpdateWithoutMValuesBooleanIndicates whether attribute features containing m-values can be edited.
capabilitiesStringInformation about the capabilities enabled for this layer.
classNameStringclass attribute of the layer's node.
columnDelimiterStringThe column delimiter.
copyrightStringCopyright information for the layer.
credentialCredentialProvides credential information for the layer such as userid and token if the layer represents a resource that is secured with token-based authentication.
dataAttributesString | String[]List of attribute fields added as custom data attributes to graphics node.
defaultDefinitionExpressionStringMetadata describing the default definition expression for the layer as defined by the service.
defaultVisibilityBooleanIndicates the default visibility for the layer.
descriptionStringThe description of the layer as defined in the map service.
displayFieldStringThe name of the layer's primary display field.
fieldsField[]The array of fields in the layer.
fullExtentExtentThe full extent of the layer.
geometryTypeStringGeometry type of the features in the layer.
graphicsGraphic[]Array of features in the layer.
htmlPopupTypeStringThe html popup type defined for the layer.
idStringID assigned to the layer.
infoTemplateInfoTemplateThe info template for the layer.
labelingInfoLabelClass[]Label definition for this layer, specified as an array of label classes.
latitudeFieldNameStringThe latitude field name.
layerIdNumberUnique ID of the layer that the FeatureLayer was constructed against.
loadErrorErrorSet if the layer failed to load.
loadedBooleanWhen the layer is loaded, the value becomes "true", and layer properties can be accessed.
longitudeFieldNameStringThe longitude field name.
maxAllowableOffsetNumberThe maximum allowable offset, only applicable for layers that are not editable.
maxScaleNumberMaximum visible scale for the layer.
minScaleNumberMinimum visible scale for the layer.
multipatchOptionStringSupports feature services whose data source is a multipatch featureclass.
  • Default is xyFootprint if geometryType is esriGeometryMultiPatch.
nameStringThe name of the layer as defined in the map service.
objectIdFieldStringThe name of the field that contains the Object ID field for the layer.
opacityNumberOpacity or transparency of layer.
refreshIntervalNumberRefresh interval of the layer in minutes.
rendererRendererThe renderer for the layer.
showAttributionBooleanWhen true, the layer's attribution is displayed on the map.
showLabelsBooleanDetermines if labels are displayed.
sourceLayerSourceThe dynamic layer or table source.
stylingBooleanIndicates whether the layer is responsible for styling graphics.
surfaceTypeStringType of vector graphics surface used to draw graphics.
suspendedBooleanWhen true, the layer is suspended.
templatesFeatureTemplate[]An array of feature templates defined in the Feature Service layer.
timeInfoTimeInfoTime information for the layer, such as start time field, end time field, track id field, layers time extent and the draw time interval.
typeStringSpecifies the type of layer.
urlStringThe url to a CSV resource.
versionNumberThe version of ArcGIS Server where the layer is published.
visibleBooleanVisibility of the layer.
visibleAtMapScaleBooleanWhen true, the layer is visible at the current map scale.
webglEnabledBooleanIndicates if WebGL is enabled on the layer.

Methods

NameReturn typeSummary
add(graphic)GraphicAdds a graphic.
attr(name, value)LayerAdds a new attribute or changes the value of an existing attribute on the layer's node.
clear()NoneClears all graphics.
clearSelection()FeatureLayerClears the current selection.
disableFeatureReduction()NoneDisables feature reduction (for example clustering) on the layer.
disableMouseEvents()NoneDisables all mouse events on the graphics layer.
enableFeatureReduction()NoneEnables feature reduction (for example clustering) on the layer using the options set in setFeatureReduction().
enableMouseEvents()NoneEnables all mouse events on the graphics layer.
getAggregateGraphics()Graphic[]Returns graphics representing the aggregation of several point features clustered together.
getDefinitionExpression()StringReturns the current definition expression.
getDomain(fieldName, options?)DomainReturns the Domain associated with the given field name.
getEditCapabilities(options?)ObjectReturns an object that describes the edit capabilities of the layer.
getFeatureReduction()ObjectReturns the options used to reduce the number of features visualized by the layer (for example clustering).
getField(fieldName)FieldReturns the Field given the specified field name.
getMap()MapReturns reference to the map control the layer is added to.
getMaxAllowableOffset()NumberReturns the current value of the maxAllowableOffset used by the layer.
getNode()HTMLElementReturns the layer's DOM node.
getOrderByFields()String[]Returns the list of fields used to order features by.
getSelectedFeatures()Graphic[]Gets the currently selected features.
getSelectionSymbol()SymbolGets the current selection symbol.
getSingleGraphics()Graphic[]Returns graphics from the layer that are not represented by aggregate graphics when feature reduction (such as clustering) is enabled.
getTimeDefinition()TimeExtentGet the current time definition applied to the feature layer.
getType(feature)FeatureTypeReturns a FeatureType describing the feature's type.
hasUpdateError()NoneIndicates whether an error is thrown after the layer updates.
hasWebGLSurface()BooleanIndicates if the layer is rendered in WebGL.
hasXYFootprint()BooleanReturns true if geometryType is esriGeometryMultipatch and multipatchOption is xyFootprint.
hide()NoneSets the visibility of the layer to "false".
isEditable()BooleanReturns true if the FeatureLayer is editable.
isFeatureReductionActive()BooleanIndicates if feature reduction (for example clustering) is active in the view.
isFeatureReductionEnabled()BooleanIndicates if feature reduction (for example clustering) is enabled.
isVisibleAtScale(scale)BooleanReturns true if the layer is visible at the given scale.
queryAttachmentInfos(objectId, callback?, errback?)DeferredQuery for information about attachments associated with the specified ObjectIds.
queryCount(query, callback?, errback?)DeferredGet a count of the number of features that satisfy the input query.
queryExtent(query, callback?, errback?)DeferredGet the extent of features that satisfy the input query.
queryFeatures(query, callback?, errback?)DeferredQuery features from the feature layer.
queryIds(query, callback?, errback?)DeferredQuery for ObjectIds.
queryRelatedFeatures(relQuery, callback?, errback?)DeferredQuery features or records, from another layer or table, related to features in this layer.
redraw()NoneRedraws all the graphics in the graphics layer.
refresh()NoneRefreshes the features in the feature layer.
remove(graphic)GraphicRemoves a graphic.
resume()NoneResumes layer drawing.
selectFeatures(query, selectionMethod?, callback?, errback?)DeferredSelects features from the FeatureLayer.
setAutoGeneralize(enable)FeatureLayerEnable or disable auto generalization for the layer.
setDefinitionExpression(expression)FeatureLayerSets the definition expression for the FeatureLayer.
setEditable(editable)FeatureLayerSet the editability of feature layers created from a feature collection.
setFeatureReduction(options)NoneSets feature reduction options on the layer (for example clustering options).
setInfoTemplate(infoTemplate)NoneSpecify or change the info template for a layer.
setLabelingInfo(labelingInfo)NoneSets labeling info on the layer.
setMaxAllowableOffset(offset)NoneSets the maximum allowable offset used when generalizing geometries.
setMaxScale(scale)NoneSet the maximum scale for the layer.
setMinScale(scale)NoneSet the minimum scale for the layer.
setOpacity(opacity)NoneInitial opacity or transparency of layer.
setRefreshInterval(interval)LayerChanges the layer's refresh interval to the given value (in minutes).
setRenderer(renderer)NoneSet the renderer for the feature layer.
setScaleRange(minScale, maxScale)NoneSet the scale range for the layer.
setSelectionSymbol(symbol)FeatureLayerSets the selection symbol for the feature layer.
setShowLabels(showLabels)NoneSets whether to display labels or not.
setTimeDefinition(definition)FeatureLayerSets the time definition for the feature layer.
setTimeOffset(offsetValue, offsetUnits)FeatureLayerTime offset allows you to display the features at a different time so they can be overlaid on top of previous or future time periods.
setUseMapTime(update)NoneDetermine if the layer will update its content based on the map's current time extent.
setVisibility(isVisible)NoneSets the visibility of the layer.
setWebGLEnabled(enable)NoneToggles WebGL rendering on/off on the layer.
show()NoneSets the visibility of the layer to "true".
suspend()NoneSuspends layer drawing.
toJson()ObjectReturns an easily serializable object representation of the layer.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
click
{
  event: <Object>
}
Fires when a graphic has been clicked.
dbl-click
{
  event: <Object>
}
Fires when a feature has been double clicked.
error
{
  error: <Error>
}
Fires when there is a problem retrieving a layer.
gdb-version-changeFired when the geodatabase version is switched.
graphic-add
{
  graphic: <Graphic>
}
Fires when a graphic is added to the GraphicsLayer.
graphic-draw
{
  graphic: <Graphic>
}
Fires when a graphic is drawn.
graphic-node-add
{
  graphic: <Graphic>,
  node: <HTMLElement>
}
Fires when a graphic's DOM node is created and added to the layer.
graphic-node-remove
{
  graphic: <Graphic>,
  node: <HTMLElement>
}
This event is fired when a graphic's DOM node is removed (consider the node destroyed).
graphic-remove
{
  graphic: <Graphic>
}
Fires when a graphic is removed from the GraphicsLayer.
graphics-clearFires when all graphics in the GraphicsLayer are cleared.
labeling-info-changeFired when labeling info on the layer changes.
load
{
  layer: <Layer>
}
Fires after layer properties for the layer are successfully populated.
mouse-down<MouseEvent> mouseEventFires when a mouse button is pressed down and the mouse cursor is on a graphic.
mouse-drag<MouseEvent> mouseEventFires while the mouse is being dragged until the mouse button is released.
mouse-move<MouseEvent> mouseEventFires as the mouse moves through a graphic on the GraphicsLayer.
mouse-out<MouseEvent> mouseEventFires as the mouse exits a graphic on the GraphicsLayer.
mouse-over<MouseEvent> mouseEventFires when the mouse first enters into a graphic on the GraphicsLayer.
mouse-up<MouseEvent> mouseEventFires when a mouse button is released and the mouse cursor is on a graphic.
opacity-change
{
  opacity: <Number>
}
Fires when the layer opacity has been changed, and returns an object with the opacity value.
query-count-complete
{
  count: <Number>
}
Fires when the query for the count is complete.
query-extent-complete
{
  count: <Number>,
  extent: <Extent>
}
Fires when queryExtent method has completed.
query-features-complete
{
  featureSet: <FeatureSet>
}
Fires when queryFeatures() is complete.
query-ids-complete
{
  objectIds: <Number[]>
}
Fires when queryIds() is complete.
query-limit-exceededFired when the feature layer could not draw all the features due to a maxRecordCount limitation on a query operation.
refresh-interval-changeThis event is fired when the layer's refreshInterval is modified.
resumeFires when a layer resumes drawing.
scale-range-changeFires when a layer's minScale and/or maxScale is changed.
scale-visibility-changeFires when a layer's scale visibility changes.
selection-clearFires after clearSelection has been called.
selection-complete
{
  features: <Graphic[]>,
  method: <Number>
}
Fires when selectFeatures() completes.
show-labels-changeFired when the feature layer's labels are changed.
suspendFires when a layer suspends drawing.
updateFires any time a layer has finished loading or updating itself.
update-end
{
  error: <Error>,
  info: <Object>
}
Fired when the layer has finished updating its content.
update-startFired when the layer begins to update its content.
visibility-change
{
  visible: <Boolean>
}
Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer.
Constructor Details

new CSVLayer(url, options?)

Creates a CSV layer.
Parameters:
<String> url Required URL to a CSV resource.
<Object> options Optional Optional parameters used to create the layer. See options descriptions for further information.
options properties:
<String> columnDelimiter Optional The column delimiter. If no delimiter is specified, one of the following is used:
  • ","
  • " "
  • ";"
  • "|"
  • "\t" (tab-delimited)
<String> copyright Optional Copyright information for the layer.
<Object> featureReduction Optional Enables feature reduction (for example clustering) on point layers. See setFeatureReduction() for more details. See the featureReduction object specification table below for options that may be set in this object.

Support for feature reduction is limited to the following scenarios:

<Object[]> fields Optional The fields property contains objects with "name", "alias" and "type" String properties. Only the "name" property is required. The value of the "type" property may be either "Date", "Number", or "String". The default is "String".
<String> latitudeFieldName Optional The latitude field name. If not specified, the API will look for following field names in the CSV source: "lat", "latitude", "y", "ycenter", "latitude83", "latdecdeg", "POINT-Y".
<String> longitudeFieldName Optional The longitude field name. If not specified, the API will look for following field names in the CSV source: "lon", "lng", "long", "longitude", "x", "xcenter", "longitude83", "longdecdeg", "POINT-X".
<Number> opacity Optional Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
<String[]> outFields Optional An array of strings which correspond to fields to include in the CSVLayer. If not specified, all the fields will be included. Added at v3.12
<Number> refreshInterval Optional Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of 0 indicates auto refresh is not enabled.
<TimeInfo> timeInfo Optional Time information for the layer, such as start time field, end time field, track id field, layers time extent and the draw time interval. Added at v3.21
csv = new CSVLayer("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv", {
  copyright: "USGS.gov",
  fields: [{ name: "time", type: "Date" }],
  timeInfo: {
    startTimeField: "time"
  }
});
<Boolean> visible Optional Visibility of the layer.
Object Specifications:
<featureReduction>
<Number> clusterRadius Optional The radius in pixels of each area in which multiple points will be summarized and visualized as a single cluster.
<InfoTemplate> infoTemplate Optional The InfoTemplate used to display summary information about aggregate graphics.
<String> type Required The reduction (or aggregation) method for reducing the features displayed in the map. The only valid value is cluster.
Sample:
var layer = new CSVLayer("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv", {
  fields: [{name: "mag", type: "Number"}]
});
Property Details

<Object> advancedQueryCapabilities

An object that contains service level metadata about whether or not the layer supports queries using statistics, order by fields, DISTINCT, pagination, query with distance, and returning queries with extents. This object contains the existing properties supportsStatistics and supportsAdvancedQueries which is returned in the new supportsOrderBy property. For backward compatibility supportsStatistics and supportsAdvancedQueries will remain properties of FeatureLayer.
"advancedQueryCapabilities" : {
  "supportsPagination" : true, 
  "supportsQueryWithDistance" : true, 
  "supportsReturningQueryExtent" : true, 
  "supportsStatistics" : true, 
  "supportsOrderBy" : true, 
  "supportsDistinct" : true
}
(Added at v3.12)
Sample:
var wildfireResponsePointsFeatureLayer = new FeatureLayer(url, featureLayerOptions);
map.addLayer(wildfireResponsePointsFeatureLayer);

wildfireResponsePointsFeatureLayer.on("load", function featureLayerLoaded(event){
  console.log("advancedQueryCapabilities"),   wildfireResponsePointsFeatureLayer.advancedQueryCapabilities);
  /* Object {supportsStatistics: true, supportsOrderBy: true, supportsDistinct: true} */
});

<Boolean> allowUpdateWithoutMValues

Indicates whether attribute features containing m-values can be edited. (Added at v3.21)
Default value: false

<String> capabilities

Information about the capabilities enabled for this layer.

<String> className

class attribute of the layer's node. (Added at v3.7)

<String> columnDelimiter

The column delimiter.

<String> copyright

Copyright information for the layer.

<Credential> credential

Provides credential information for the layer such as userid and token if the layer represents a resource that is secured with token-based authentication. This value is available after the layer has been loaded i.e. layer.loaded is true. (Added at v2.5)

<String | String[]> dataAttributes

List of attribute fields added as custom data attributes to graphics node. Applicable only when layer surfaceType is "svg". (Added at v3.7)

<String> defaultDefinitionExpression

Metadata describing the default definition expression for the layer as defined by the service. The default definition expression limits the features available for display and query. You cannot override this value but you define additional filters on the default expression using the setDefinitionExpression method. For example, if the default definition expression is set to display data where "STATE_NAME = 'California'" you could use setDefinitionExpression to only display a subset of the features in California, for example using "COUNTY='San Diego'".

<Boolean> defaultVisibility

Indicates the default visibility for the layer. (Added at v3.0)
Known values: true | false
Sample:

var isVisible = layer.defaultVisibility;

<String> description

The description of the layer as defined in the map service.

<String> displayField

The name of the layer's primary display field. The value of this property matches the name of one of the fields of the layer.

<Field[]> fields

The array of fields in the layer.

<Extent> fullExtent

The full extent of the layer.

<String> geometryType

Geometry type of the features in the layer. Can be one of the following: "esriGeometryPoint", "esriGeometryPolygon" or "esriGeometryPolyline".

<Graphic[]> graphics

Array of features in the layer.

<String> htmlPopupType

The html popup type defined for the layer. View the constants table for a list of valid values.

<String> id

ID assigned to the layer. If not assigned, esri.Map assigns value. By default, the ID of the layer is "layer" followed by a number. The ID can be user defined only in the layer constructor.
Sample:
  • Setting the layer ID in the layer constructor.
    require([
      "esri/layers/ArcGISDynamicMapServiceLayer", ... 
    ], function(ArcGISDynamicMapServiceLayer, ... ) {
      var population = new ArcGISDynamicMapServiceLayer("http://myserver/arcgis/rest/population/MapServer/Layers", {id:"population"});
      ...
    });
    
  • Setting the layer ID after a layer is initialized.
    population.id = "population";
    
  • Retrieving the layer ID.
    function getMapLayers() {
      for (var j=0, jl=map.layerIds.length; j<jl; j++) {
        var currentLayer = map.getLayer(map.layerIds[j]);
        alert("id: " + currentLayer.id);
      }
    }
    

<InfoTemplate> infoTemplate

The info template for the layer. (Added at v3.9)

<LabelClass[]> labelingInfo

Label definition for this layer, specified as an array of label classes. Use this property to specify any changes to the structure of the label. For example, label expression, placement, and size can be modified and passed to this property. (Added at v3.10)
Sample:
labelingInfo: [{
  "labelExpression": "", //deprecated, labelExpressionInfo property should be used in its place
  "labelExpressionInfo": {
   {"value": "City Of {CITY_NAME} has population {POPULATION}"}
  },
  "useCodedValues":  //parameters used when attribute field has domain values,
  "labelPlacement": "above-right",
  "symbol": {...}, //TextSymbol used for labeling
  "minScale": 0, //specified scale range where labels are visible
  "maxScale": 5000,
  //fieldInfos structure describes attribute field formatting
  "fieldInfos": [
    { fieldName: "created_date", format: { dateFormat: "shortDate"} }, //date/time formatting 
    { fieldName: "last_edited_date", format: { dateFormat: "longDate"} },  //date/time formatting
    { fieldName: "eventtype", format: { places: 6, digitSeparator: true } } //numeric formatting
  ],
  "where": "POP_RANK > 2 AND POP_RANK < 4" //where clause applied on labels
}]

<String> latitudeFieldName

The latitude field name.

<Number> layerId

Unique ID of the layer that the FeatureLayer was constructed against.

<Error> loadError

Set if the layer failed to load. (Added at v3.9)

<Boolean> loaded

When the layer is loaded, the value becomes "true", and layer properties can be accessed. The onLoad event is also fired.
Known values: true | false

<String> longitudeFieldName

The longitude field name.

<Number> maxAllowableOffset

The maximum allowable offset, only applicable for layers that are not editable. (Added at v2.7)

<Number> maxScale

Maximum visible scale for the layer. If the map is zoomed in beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a maximum scale. (Added at v3.1)
Default value: 0

<Number> minScale

Minimum visible scale for the layer. If the map is zoomed out beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a visible scale. (Added at v3.1)
Default value: 0

<String> multipatchOption

Supports feature services whose data source is a multipatch featureclass.
  • Default is xyFootprint if geometryType is esriGeometryMultiPatch. Otherwise, undefined.
  • User can override this property with a different choice in the future when FS supports it.
  • Queries made through the FeatureLayer will include multipatchOption parameter if returnGeometry is true.
  • Applies to snapshot, ondemand, selectFeatures, and queryFeatures
Note: Requires ArcGIS 10.3 and above. (Added at v3.12)
Default value: xyFootprint
Sample:
var infoTemplate = new InfoTemplate("Attributes", "${*}");

var url = "http://servername.fqdn.suffix/arcgis/rest/services/Hosted/pasadena/FeatureServer/0";
var featureLayerOptions = {
  id: "cities",
  mode: FeatureLayer.MODE_AUTO,
  outFields: ["*"],
  infoTemplate: infoTemplate
};
var citiesFeatureLayer = new FeatureLayer(url, featureLayerOptions);

map.addLayer(citiesFeatureLayer);

<String> name

The name of the layer as defined in the map service.

<String> objectIdField

The name of the field that contains the Object ID field for the layer.

<Number> opacity

Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
Known values: 0.0 - 1.0
Default value: 1.0

<Number> refreshInterval

Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of 0 indicates auto refresh is not enabled.
Default value: 0

<Renderer> renderer

The renderer for the layer.

<Boolean> showAttribution

When true, the layer's attribution is displayed on the map. (Added at v3.1)
Known values: true | false
Default value: true

<Boolean> showLabels

Determines if labels are displayed. When false, labels for the layer are not displayed.

If the FeatureLayer has labeling defined on it, labels will automatically display if the Map's showLabels is true.

If you do not wish to have your feature layer label, you can override this behavior by setting its showLabels property to false.

NOTE: In order for the labels to display, all fields used by the labelingInfo should be set in outFields. In addition, only simple labeling is supported, for example {CITY_NAME}. For example, SQL keywords such as "CONCAT" are not supported. Consider using the LabelLayer class where you can specify the textExpression if needing more functionality.
Added at v3.11

Known values: true | false
Default value: true

<LayerSource> source

The dynamic layer or table source. (Added at v2.7)

<Boolean> styling

Indicates whether the layer is responsible for styling graphics. When true, styling is based on graphics symbol or the layer's renderer. When false, graphics styling is disabled. Applicable only when layer surfaceType is "svg". (Added at v3.7)
Known values: true | false

<String> surfaceType

Type of vector graphics surface used to draw graphics. (Added at v3.7)
Known values: "svg" | "canvas-2d" | "vml"
Default value: "svg" on all browsers - except IE8 or earlier where "vml" is used to draw graphics.

<Boolean> suspended

When true, the layer is suspended. A layer is considered to be suspended when one of the following is true:
  • The layer is hidden.
  • The layer is not visible at the current map scale.
  • The layer is explicitly suspended by calling the Layer.suspend method.
(Added at v3.1)
Known values: true | false

<FeatureTemplate[]> templates

An array of feature templates defined in the Feature Service layer. Only applicable for ArcGIS Server Feature Service layers.
Sample:
require([
  "esri/layers/FeatureLayer", "dojo/_base/array", ... 
], function(FeatureLayer, array, ... ) {
  var layer = new FeatureLayer( ... );
  var templates = layer.templates;
  array.forEach(templates,function(template){
    console.log(template.description);
    console.log(template.name);
  });
  ...
});

<TimeInfo> timeInfo

Time information for the layer, such as start time field, end time field, track id field, layers time extent and the draw time interval. Only applicable if the layer is time aware.

<String> type

Specifies the type of layer. Can be "Feature Layer" or "Table".

<String> url

The url to a CSV resource.

<Number> version

The version of ArcGIS Server where the layer is published. Examples are 9.3, 9.31, 10. (Added at v2.1)

<Boolean> visible

Visibility of the layer.
Known values: true | false
Default value: true

<Boolean> visibleAtMapScale

When true, the layer is visible at the current map scale. (Added at v3.1)
Known values: true | false

<Boolean> webglEnabled

Indicates if WebGL is enabled on the layer. Note that this doesn't indicate that WebGL is actually being used in the rendering. Use hasWebGLSurface() to check if the layer is drawn with WebGL. (Added at v3.24)
Default value: true
Method Details

add(graphic)

Adds a graphic.
Return type: Graphic
Parameters:
<Graphic> graphic Required The graphic to add.
Sample:
require([
  "esri/symbols/SimpleFillSymbol", "esri/graphic", ... 
], function(SimpleFillSymbol, Graphic, ... ) {
  function addGraphic(geometry) {
    var symbol = new SimpleFillSymbol();
    graphicsLayer.add(new Graphic(geometry, symbol));
  }
  ...
});

attr(name, value)

Adds a new attribute or changes the value of an existing attribute on the layer's node. Removes the attribute if the value is null or undefined. (Added at v3.7)
Return type: Layer
Parameters:
<String> name Required The name of the attribute.
<String> value Required The value of the attribute. Set this value as null to remove the attribute.

clear()

Clears all graphics.
Sample:

graphicsLayer.clear();

clearSelection()

Clears the current selection.
Return type: FeatureLayer

disableFeatureReduction()

Disables feature reduction (for example clustering) on the layer. This is useful for certain workflows, such as editing, where feature reduction can hinder the desired user experience. Only applicable to point layers. (Added at v3.22)
Sample:
featureLayer.disableFeatureReduction();

disableMouseEvents()

Disables all mouse events on the graphics layer.

enableFeatureReduction()

Enables feature reduction (for example clustering) on the layer using the options set in setFeatureReduction(). Only applicable to point layers. (Added at v3.22)
Sample:
  featureLayer.enableFeatureReduction();

enableMouseEvents()

Enables all mouse events on the graphics layer.

getAggregateGraphics()

Returns graphics representing the aggregation of several point features clustered together. Only applicable when feature reduction is enabled. (Added at v3.22)
Return type: Graphic[]
Sample:
var aggregateGraphics = featureLayer.getAggregateGraphics();

getDefinitionExpression()

Returns the current definition expression.
Return type: String

getDomain(fieldName, options?)

Returns the Domain associated with the given field name. This being either a Coded Value Domain or Range Domain. (Added at v3.12)
Return type: Domain
Parameters:
<String> fieldName Required Name of the attribute field.
<Object> options Optional Please see the options object specification table below.
Object Specifications:
<options>
<Graphic> feature Required The feature in which the Domain is retrieved.
NOTE: If the layer has sub-types, the domain will be calculated based on the feature type and domain defined for that type.

getEditCapabilities(options?)

Returns an object that describes the edit capabilities of the layer. The returned object has the following properties:
<Boolean> canCreate When true, new features can be created.
<Boolean> canUpdate When true, existing features can be updated.
<Boolean> canDelete When true, features can be deleted.
(Added at v2.6)
Return type: Object
Parameters:
<Object> options Optional If the layer supports ownership based access control, use the options to determine if the specified user can edit features. Ownership based access control requires ArcGIS Server services version 10.1 or greater. See the object specifications table below for the structure of the options object.
Object Specifications:
<options>
<Graphic> feature Required Check to see if the specified feature can be edited by the specified user.
<graphic> feature Required Check to see if the specified feature can be edited by the specified user.
<String> userId Required The name of the currently logged in user. If the application uses the IdentityManager the IdentityManager supplies the layer with the userId so this parameter is not required.
<String> userId Required The name of the currently logged in user. If the application uses the IdentityManager the IdentityManager supplies the layer with the userId so this parameter is not required.
Sample:

var capabilities = featureLayer.getEditCapabilities();

if(capabilities.canUpdate){

  console.log("This layer can be updated");

}

getFeatureReduction()

Returns the options used to reduce the number of features visualized by the layer (for example clustering). This is only applicable to point layers. See setFeatureReduction() for more details. (Added at v3.22)
Return type: Object
Sample:
featureLayer.getFeatureReduction();

getField(fieldName)

Returns the Field given the specified field name. (Added at v3.12)
Return type: Field
Parameters:
<String> fieldName Required Name of the attribute field.

getMap()

Returns reference to the map control the layer is added to. Returns null or undefined if it is not added to a map. (Added at v3.7)
Return type: Map

getMaxAllowableOffset()

Returns the current value of the maxAllowableOffset used by the layer. For non-editable layers in on-demand mode if autoGeneralize is enabled the maxAllowableOffset is set to the current map resolution. (Added at v2.7)
Return type: Number
Sample:

 var currentOffset = featureLayer.getMaxAllowableOffset();

getNode()

Returns the layer's DOM node. (Added at v3.7)
Return type: HTMLElement

getOrderByFields()

Returns the list of fields used to order features by. For queries as well as rendering. (Added at v3.8)
Return type: String[]

getSelectedFeatures()

Gets the currently selected features.
Return type: Graphic[]

getSelectionSymbol()

Gets the current selection symbol.
Return type: Symbol

getSingleGraphics()

Returns graphics from the layer that are not represented by aggregate graphics when feature reduction (such as clustering) is enabled. (Added at v3.22)
Return type: Graphic[]
Sample:
var singleGraphics = featureLayer.getSingleGraphics();

getTimeDefinition()

Get the current time definition applied to the feature layer.
Return type: TimeExtent
Sample:
require([
  "esri/map", "esri/layers/FeatureLayer", "esri/layers/TimeInfo", ... 
], function(Map, FeatureLayer, TimeInfo, ... ) {
  var timeSlider = new TimeSlider( ... );
  var featureLayer = new FeatureLayer();
  timeSlider.createTimeStopsByTimeInterval(featureLayer.getTimeDefinition(), 
    1, TimeInfo.UNIT_HOURS);
  ...
});

getType(feature)

Returns a FeatureType describing the feature's type.
NOTE: This is applicable if the layer containing the feature has a TypeIdField. (Added at v3.12)
Return type: FeatureType
Parameters:
<Graphic> feature Required A feature from this layer.

hasUpdateError()

Indicates whether an error is thrown after the layer updates. (Added at v3.24)

hasWebGLSurface()

Indicates if the layer is rendered in WebGL. (Added at v3.24)
Return type: Boolean

hasXYFootprint()

Returns true if geometryType is esriGeometryMultipatch and multipatchOption is xyFootprint. When true, the FeatureLayer will behave as if it were a polygon.
  • Auto generalization will be enabled by default.
  • Auto mode will treat the layer like a polygon layer.
(Added at v3.12)
Return type: Boolean
Sample:
citiesFeatureLayer.on("load", function featureLayerLoaded(event){
  var hasXYFootprint = citiesFeatureLayer.hasXYFootprint();
  console.log("Contains xyfootprints:", hasXYFootprint);
});

hide()

Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.

isEditable()

Returns true if the FeatureLayer is editable. If the layer is editable, one or more of the following operations can be performed depending on the permissions set on the service.

  • Add new features.
  • Modify the geometry and attributes of existing features.
  • Delete features.

To see which of the above editing actions may be performed on the layer, execute getEditCapabilities() on the layer after verifying that isEditable() returns true.

Return type: Boolean

isFeatureReductionActive()

Indicates if feature reduction (for example clustering) is active in the view. Feature reduction is active at all scales. At any given scale, if there are features that do not fall within a cluster, they are displayed as individual features. This method is only applicable to point layers when feature reduction is enabled. (Added at v3.22)
Return type: Boolean
Sample:
featureLayer.isFeatureReductionActive();

isFeatureReductionEnabled()

Indicates if feature reduction (for example clustering) is enabled. Only applicable to point layers. See also setFeatureReduction(). (Added at v3.22)
Return type: Boolean
Sample:
featureLayer.isFeatureReductionEnabled();

isVisibleAtScale(scale)

Returns true if the layer is visible at the given scale. (Added at v3.1)
Return type: Boolean
Parameters:
<Number> scale Required The scale at which to check if the layer is visible.

queryAttachmentInfos(objectId, callback?, errback?)

Query for information about attachments associated with the specified ObjectIds.
Return type: Deferred
Parameters:
<Number> objectId Required The ObjectId for the feature to query for attachment information.
<Function> callback Optional The function to call when the method has completed.
<Function> errback Optional An error object is returned if an error occurs.

queryCount(query, callback?, errback?)

Get a count of the number of features that satisfy the input query. Valid only for layers published using ArcGIS Server 10 SP1 or greater. Layers published with earlier versions of ArcGIS Server return an error to the error callback. (Added at v2.1)
Return type: Deferred
Parameters:
<Query> query Required

The input query. The query object has the following restrictions to avoid conflicts between layer and map properties.

  • outFields specified by the query object are overridden by the outFields specified in the FeatureLayer constructor.
  • The returnGeometry value specified by the query object is ignored and true is used.
  • The outSpatialReference set by the query object is ignored and the map's spatial reference is used.
<Function> callback Optional The function to call when the method has completed.
<Function> errback Optional An error object is returned if an error occurs.
Sample:
require([
  "esri/tasks/query", "FeatureLayer", ... 
], function(Query, FeatureLayer, ... ) {
  var query = new Query();
  var featureLayer = new FeatureLayer( ... );
  query.where = "POP90_SQMI < 100";
  featureLayer.queryCount(query, function(count) {
    console.log(count + " features satisfied the input query");
  }, function(error) {
    console.log(error);
  });      
  ...
});

queryExtent(query, callback?, errback?)

Get the extent of features that satisfy the input query. The count of features that satisfy the input query is returned as well. This is valid only for hosted feature services on arcgis.com and for ArcGIS Server 10.3.1 and later. (Added at v3.9)
Return type: Deferred
Parameters:
<Query> query Required The query definition.
<Function> callback Optional The function called when the method has completed.
<Function> errback Optional The function called when error occurred.

queryFeatures(query, callback?, errback?)

Query features from the feature layer. Layer definition and time definition are honored. Whenever possible the feature layer will perform the query on the client.
Return type: Deferred
Parameters:
<Query> query Required

The input query. The query object has the following restrictions to avoid conflicts between layer and map properties.

  • outFields specified by the query object are overridden by the outFields specified in the FeatureLayer constructor.
  • The returnGeometry value specified by the query object is ignored and true is used. As of version 3.5 the returnGeometry value is honored.
  • The outSpatialReference set by the query object is ignored and the map's spatial reference is used.
<Function> callback Optional The function to call when the method has completed.
<Function> errback Optional An error object is returned if an error occurs.
Sample:
require([
  "esri/layers/FeatureLayer", "esri/tasks/query", ... 
], function(FeatureLayer, Query, ... ) {
  featureLayer = new FeatureLayer( ... );
  var query = new Query();
  query.objectIds = [features[0].attributes.OBJECTID];
  query.outFields = [ "*" ];
  // Query for the features with the given object ID
  featureLayer.queryFeatures(query, function(featureSet) {
  });
  ...
});

queryIds(query, callback?, errback?)

Query for ObjectIds. There is no limit on the number of ObjectIds that are returned from the server. Like queryFeatures this operation will perform queries on the client (browser) whenever possible. Valid only for layers published using ArcGIS Server 10 SP1 or greater.
Return type: Deferred
Parameters:
<Query> query Required

The input query. The query object has the following restrictions to avoid conflicts between layer and map properties.

  • outFields specified by the query object are overridden by the outFields specified in the FeatureLayer constructor.
  • The returnGeometry value specified by the query object is ignored and true is used.
  • The outSpatialReference set by the query object is ignored and the map's spatial reference is used.
<Function> callback Optional The function to call when the method has completed.
<Function> errback Optional An error object is returned if an error occurs.
Sample:
require([
  "esri/layers/FeatureLayer", "esri/tasks/query", ... 
], function(FeatureLayer, Query, ... ) {
  var featureLayer = new FeatureLayer( ... );
  // create a query to fetch object IDs for all records
  var query = new Query();
  query.where = "1=1";
  
  featureLayer.queryIds(query, function(objectIds) {
    //do something with the objectIds here
  });
  ...
});

queryRelatedFeatures(relQuery, callback?, errback?)

Query features or records, from another layer or table, related to features in this layer.
Return type: Deferred
Parameters:
<RelationshipQuery> relQuery Required The input query.
<Function> callback Optional The function to call when the method has completed.
<Function> errback Optional An error object is returned if an error occurs.
Sample:
require([
  "esri/layers/FeatureLayer", "esri/tasks/RelationshipQuery", "dojo/_base/connect", ... 
], function(FeatureLayer, RelationshipQuery, connect, ... ) {
  var featureLayer = new FeatureLayer( ... );
  var relatedQuery = new RelationshipQuery();
  relatedQuery.outFields = ["AGREE_WITH_INCIDENT"];
  relatedQuery.relationshipId = 1;
  
  //query for the features related to the "clicked" feature
  connect.connect(featureLayer, "onClick", function(evt) {
    graphicAttributes = evt.graphic.attributes;
    relatedQuery.objectIds = [graphicAttributes.OBJECTID];
    featureLayer.queryRelatedFeatures(relatedQuery,relatedRecords);
  }
  ...
});

redraw()

Redraws all the graphics in the graphics layer. Unlike refresh(), redraw does not re-query features from the server. (Added at v3.3)

refresh()

Refreshes the features in the feature layer. The feature layer requeries all the features in the service, except the selected features, and updates itself.

remove(graphic)

Removes a graphic.
Return type: Graphic
Parameters:
<Graphic> graphic Required The graphic to remove.

resume()

Resumes layer drawing. (Added at v3.1)

selectFeatures(query, selectionMethod?, callback?, errback?)

Selects features from the FeatureLayer. Layer properties like layer definition and time definition are honored. The selection method defines how query results are passed to the selection. The feature layer will highlight the current selection if a selection symbol has been defined. Whenever possible, the feature layer will perform the query operation on the client (browser).
Return type: Deferred
Parameters:
<Query> query Required

The input query. The query object has the following restrictions to avoid conflicts between layer and map properties.

  • outFields specified by the query object are overridden by the outFields specified in the FeatureLayer constructor.
  • The returnGeometry value specified by the query object is ignored and true is used.
  • The outSpatialReference set by the query object is ignored and the map's spatial reference is used.
<Number> selectionMethod Optional The selection method defines how the rest of the selection is combined with the existing selection. See Constants table for valid values. The default option is to create a new selection.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onSelectionComplete event.
<Function> errback Optional An error object is returned if an error occurs.
Sample:
require([
  "esri/tasks/query", "esri/layers/FeatureLayer", ... 
], function(Query, FeatureLayer, ... ) {
  var query = new Query();
  var featureLayer = new FeatureLayer( ... );
  query.geometry = feature.geometry;
  featureLayer.selectFeatures(query,FeatureLayer.SELECTION_NEW);
  ...
});

setAutoGeneralize(enable)

Enable or disable auto generalization for the layer. Note that auto generalization is only applicable to non-editable feature layers in on-demand mode. (Added at v2.7)
Return type: FeatureLayer
Parameters:
<Boolean> enable Required When true, auto generalize is enabled. Default value for non-editable on-demand feature layers is true.
Sample:
featureLayer.setAutoGeneralize(false);

setDefinitionExpression(expression)

Sets the definition expression for the FeatureLayer. Only the features that match the definition expression are displayed. A definition expression limits the features available for display and queries by applying constraints to the layer's attribute fields. Setting a definition expression is useful when the dataset is large and you don't want to bring everything to the client for analysis. This method is typically called before adding the layer to the map. If the method is called after the layer is added to the map the layer will refresh itself to reflect the new definition expression.

This definition expression is combined with the layer's default definition expression which results in a further restriction of the layer.

Return type: FeatureLayer
Parameters:
<String> expression Required The definition expression to apply. For example, "TYPE='Park'"
Sample:
featureLayer.setDefinitionExpression("STATE_NAME = 'South Carolina'");

setEditable(editable)

Set the editability of feature layers created from a feature collection. This method is only valid for feature layers created from feature collections.

When the feature layer's editability is updated the onCapabilitiesChange event is fired. Use the isEditable method to determine if the layer is editable.

(Added at v2.6)
Return type: FeatureLayer
Parameters:
<Boolean> editable Required When true, the layer will be set as editable.
Sample:

featureLayer.setEditable(true);

setFeatureReduction(options)

Sets feature reduction options on the layer (for example clustering options). When set, features in the layer will aggregate, thus changing the visualization. This will not change the renderer of the layer. See the valid parameters in the table below.

Support for feature reduction is limited to the following scenarios:

  • Point data in FeatureLayer (from service or FeatureCollection) and CSVLayer.
  • The map must have a spatial reference of Web Mercator or WGS84.
  • If the layer contains more than 50,000 features, then only the first 50,000 will be clustered.
  • A FeatureLayer created from a service URL must point to a service that supports pagination (ArcGIS Server version 10.3.1 or higher).
  • When editing is initiated with the Editor widget, then feature reduction is disabled until the Editor widget is destroyed.
  • Feature reduction is disabled when the layer has one of the following renderers: HeatmapRenderer, BlendRenderer, TemporalRenderer, or ScaleDependentRenderer.
(Added at v3.22)
Parameters:
<Object> options Required Options for reducing (or aggregating) the features in the map. See the table below for more details.
Object Specifications:
<options>
<Number> clusterRadius Optional The radius in pixels of each area in which multiple points will be summarized and visualized as a single cluster. The default value is 80.
<InfoTemplate> infoTemplate Optional The InfoTemplate used to display summary information about aggregate graphics.
<String> type Required The reduction (or aggregation) method for reducing the features displayed in the map. The only valid type is cluster.
Sample:
  featureLayer.setFeatureReduction({
    type: "cluster",
    clusterRadius: 60
  });

setInfoTemplate(infoTemplate)

Specify or change the info template for a layer. (Added at v2.2)
Parameters:
<InfoTemplate> infoTemplate Required The new info template.
Sample:
require([
  "esri/InfoTemplate", ... 
], function(InfoTemplate, ... ) {
    var template = new InfoTemplate();

    template.setTitle("${qAddress}");

    template.setContent(getTextContent);

    featureLayer.setInfoTemplate(template);
  ...
});

setLabelingInfo(labelingInfo)

Sets labeling info on the layer. Input value is an array of LabelClass objects. (Added at v3.10)
Parameters:
<LabelClass[]> labelingInfo Required This is the label definition for this layer, specified as an array of label classes. Use this property to specify any changes to the structure of the label. For example, label expression, placement, and size can be modified and passed to this property.
Sample:
//make sure the Map's showLabels option is set to true
  var map = new Map("map", {
    basemap: "streets",
    center:[-80, 30],
    zoom: 5,
    showLabels : true
  });
 
//create featurelayer
  var flayer = new FeatureLayer(url, {
    outFields: ["*"] //make sure field to label is specified here in outFields
  });


//create a text symbol and renderer to define the style of labels
   var labelSymbol = new TextSymbol(); 
   var labelRenderer = new SimpleRenderer(labelSymbol);


var json = {
  "labelExpressionInfo": {"value": "{LocalTime}"},
  "useCodedValues": false,
  "labelPlacement":"above-right",
  "fieldInfos": [{fieldName: "LocalTime",format: { "dateFormat": "shortDate"}}]
  };

//create instance of LabelClass
  var lc = new LabelClass(json);
  lc.symbol = labelSymbol; // symbol also can be set in LabelClass' json
  flayer.setLabelingInfo([ lc ]);

setMaxAllowableOffset(offset)

Sets the maximum allowable offset used when generalizing geometries. The offset is in the units of the spatialReference. This is ignored when working with editable layers.
Parameters:
<Number> offset Required The maximum allowable offset.
Sample:
require([
  "esri/layers/FeatureLayer", ... 
], function(FeatureLayer, ... ) {
  featureLayer = new FeatureLayer(featureLayerUrl, {
    maxAllowableOffset: 1000
  });
  ...
});

setMaxScale(scale)

Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number> scale Required The maximum scale at which the layer is visible.

setMinScale(scale)

Set the minimum scale for the layer. (Added at v3.1)
Parameters:
<Number> scale Required The minimum scale at which the layer is visible.

setOpacity(opacity)

Initial opacity or transparency of layer. Not supported in Internet Explorer.
Parameters:
<Number> opacity Required Value from 0 to 1, where 0 is 100% transparent and 1 has no transparency. The default value is 1.
Sample:
featureLayer.setOpacity(.50);

setRefreshInterval(interval)

Changes the layer's refresh interval to the given value (in minutes). Non-zero value sets up automatic layer refresh at the specified interval. Value of 0 stops auto refresh. (Added at v3.7)
Return type: Layer
Parameters:
<Number> interval Required Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of 0 indicates auto refresh is not enabled.

setRenderer(renderer)

Set the renderer for the feature layer.
Parameters:
<Renderer> renderer Required The renderer to apply to the feature layer
Sample:
require([
  "esri/symbols/SimpleFillSymbol", "esri/Color", "esri/renderers/SimpleRenderer", ... 
], function(SimpleFillSymbol, Color, SimpleRenderer, ... ) {
  var symbol = new SimpleFillSymbol().setColor(new Color([255,0,0,0.5]));

  var renderer = new SimpleRenderer(symbol);

  featureLayer.setRenderer(renderer);
  ...
});

setScaleRange(minScale, maxScale)

Set the scale range for the layer. If minScale and maxScale are set to 0 then the layer will be visible at all scales. (Added at v2.5)
Parameters:
<Number> minScale Required The minimum scale for the layer. If the map is zoomed out beyond the specified scale the layer will not be visible. A value of 0 means the layer does not have a minimum scale.
<Number> maxScale Required The maximum scale for the layer. If the map is zoomed out beyond the specified scale the layer will not be visible. A value of 0 means the layer does not have a maximum scale.
Sample:

featureLayer.setScaleRange(591657528,147914381);

setSelectionSymbol(symbol)

Sets the selection symbol for the feature layer. If no symbol is specified, features are drawn using the layer's renderer.
Return type: FeatureLayer
Parameters:
<Symbol> symbol Required Symbol for the current selection. Make sure the symbol type is appropriate for the geometry type of the layer.
Sample:
require([
  "esri/layers/FeatureLayer", "esri/symbols/SimpleFillSymbol", "esri/Color", ... 
], function(FeatureLayer, SimpleFillSymbol, Color, ... ) {
  var featureLayer = new FeatureLayer( ... );
  var selectionSymbol = new SimpleFillSymbol().setColor(new Color([255,255,0,0.5]));
  featureLayer.setSelectionSymbol(selectionSymbol);
  ...
});

setShowLabels(showLabels)

Sets whether to display labels or not. Set to false to turn off labeling. (Added at v3.11)
Parameters:
<Boolean> showLabels Required Set to true to show labels.

setTimeDefinition(definition)

Sets the time definition for the feature layer. A time definition temporarily filters the features in the layer to match the specified time extent. Only applicable for time-aware layers. Only supported when the feature layer is in snapshot mode.

In addition to time definition, time-aware layers also support the time extent set on the map. Time-aware layers automatically update when the map's time extent is changed, similar to how layers react when the map's spatial reference is modified. If a layer's time definition is set to display features between 1970 and 1975 and the map has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975

Return type: FeatureLayer
Parameters:
<TimeExtent> definition Required The new time extent used to filter the layer.
Sample:
require([
  "esri/TimeExtent", "esri/layers/FeatureLayer", ... 
], function(TimeExtent, FeatureLayer, ... ) {
  var defn = new TimeExtent();
  var featureLayer( ... );
  defn.startTime = new Date("November 30,2009 6:00:00")
  defn.endTime = new Date("November 30, 2009 8:00:00");
  featureLayer.setTimeDefinition(defn);
  ...
});

setTimeOffset(offsetValue, offsetUnits)

Time offset allows you to display the features at a different time so they can be overlaid on top of previous or future time periods. For example, to visualize the growth pattern of two wild fires that happened in two different years, one of the layers can be given an offset that will cause it to appear as if the fire started at the same time as the other fire. Note that the offset does not change the temporal component of the data itself and has no effect if the layer is not time aware.

Example: If a layer has data recorded for the year 1970, an offset value of 2 years would temporarily shift the data to 1972 (for display purposes only, query and selection are not affected by offset).

Return type: FeatureLayer
Parameters:
<Number> offsetValue Required The length of time to offset from "this" time. Specify a positive or negative whole number.
<String> offsetUnits Required Units in which the offset is specified. See the TimeInfo constants for valid values.

setUseMapTime(update)

Determine if the layer will update its content based on the map's current time extent. Default value is true. (Added at v2.2)
Parameters:
<Boolean> update Required When false the layer will not update its content based on the map's time extent. Default value is true.

setVisibility(isVisible)

Sets the visibility of the layer. When true, the layer is visible.
Parameters:
<Boolean> isVisible Required Set the visibility of the layer.

setWebGLEnabled(enable)

Toggles WebGL rendering on/off on the layer. (Added at v3.24)
Parameters:
<Boolean> enable Required Indicates whether to enable WebGL on the layer.
Sample:
layer.setWebGLEnabled(true);

show()

Sets the visibility of the layer to "true".

suspend()

Suspends layer drawing. (Added at v3.1)

toJson()

Returns an easily serializable object representation of the layer. Regardless of the layer's mode of operation, only features currently available on the client are included.


{

  layerDefinition: <Object>,

    featureSet: {

    features:<Object[]>

  }

}

Return type: Object
Event Details
[ On Style Events | Connect Style Event ]

click

Fires when a graphic has been clicked. Should be used in favor of onClick. (Added at v3.5)
Event Object Properties:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

dbl-click

Fires when a feature has been double clicked. (Added at v3.6)
Event Object Properties:
<Object> event The returned object contains screenPoint, mapPoint, and graphic.
Sample:
require([
  "dojo/_base/connect", "esri/toolbars/Edit", ... 
], function(connect, Edit, ... ) {
  var editToolbar = new Edit( ... );
  connect.connect(firePerimeterFL, "onDblClick", function(evt) {
    editToolbar.activate(Edit.EDIT_VERTICES , evt.graphic);
  });
  ...
});

error

Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
Event Object Properties:
<Error> error ArcGIS Server error message returned in a JavaScript error object.

gdb-version-change

Fired when the geodatabase version is switched. (Added at v3.5)

graphic-add

Fires when a graphic is added to the GraphicsLayer. Should be used in favor of onGraphicAdd. (Added at v3.5)
Event Object Properties:
<Graphic> graphic The added graphic.

graphic-draw

Fires when a graphic is drawn. A graphic is drawn or redrawn when:
  • When it is added to the layer.
  • When Geometry or Symbol is modified.
  • When it enters the viewport and intersects the map extent.
  • When the layer is redrawn.
(Added at v3.7)
Event Object Properties:
<Graphic> graphic Graphic being drawn. When the layer surfaceType is "svg" or "vml", the graphic's DOM node is accessible with graphic.getNode().

graphic-node-add

Fires when a graphic's DOM node is created and added to the layer. Fires only when the layer surfaceType is "svg" or "vml". (Added at v3.7)
Event Object Properties:
<Graphic> graphic Graphic being drawn.
<HTMLElement> node Graphic's DOM node.

graphic-node-remove

This event is fired when a graphic's DOM node is removed (consider the node destroyed). The DOM node of a graphic is removed when:
  • Graphic is removed from the layer.
  • Graphic exits the viewport on map navigation.
  • When a symbol change cannot be applied to the Graphic without replacing the current node with a new one. For example: when a marker symbol is changed from SimpleMarkerSymbol to PictureMarkerSymbol, onGraphicNodeRemove will be fired for the node that is being replaced (SVG Circle) and onGraphicNodeAdd will be fired for the new node (SVG Image).
Fires only when the layer surfaceType is "svg" or "vml". (Added at v3.7)
Event Object Properties:
<Graphic> graphic Graphic being drawn.
<HTMLElement> node Graphic's DOM node.

graphic-remove

Fires when a graphic is removed from the GraphicsLayer. Should be used in favor of onGraphicRemove. (Added at v3.5)
Event Object Properties:
<Graphic> graphic The removed graphic.

graphics-clear

Fires when all graphics in the GraphicsLayer are cleared. Should be used in favor of onGraphicsClear. (Added at v3.5)

labeling-info-change

Fired when labeling info on the layer changes. (Added at v3.10)

load

Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map. Should be used in favor of onLoad. (Added at v3.5)
Event Object Properties:
<Layer> layer The loaded layer.

mouse-down

Fires when a mouse button is pressed down and the mouse cursor is on a graphic. Should be used in favor of onMouseDown. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-drag

Fires while the mouse is being dragged until the mouse button is released. Should be used in favor of onMouseDrag. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-move

Fires as the mouse moves through a graphic on the GraphicsLayer. Should be used in favor of onMouseMove. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-out

Fires as the mouse exits a graphic on the GraphicsLayer. Should be used in favor of onMouseOut. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-over

Fires when the mouse first enters into a graphic on the GraphicsLayer. Should be used in favor of onMouseOver. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-up

Fires when a mouse button is released and the mouse cursor is on a graphic. Should be used in favor of onMouseUp. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

opacity-change

Fires when the layer opacity has been changed, and returns an object with the opacity value. Should be used in favor of onOpacityChange. (Added at v3.5)
Event Object Properties:
<Number> opacity Fires when the layer opacity (transparency) changes. A number property named opacity that indicates the new opacity. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.

query-count-complete

Fires when the query for the count is complete. This event is only available for layers published using ArcGIS Server 10 SP1 or later. Should be used in favor of onQueryCountComplete. (Added at v3.5)
Event Object Properties:
<Number> count The number of features that satisfy the input query.

query-extent-complete

Fires when queryExtent method has completed. (Added at v3.9)
Event Object Properties:
<Number> count The count of features.
<Extent> extent The extent of features.

query-features-complete

Fires when queryFeatures() is complete. Should be used in favor of onQueryFeaturesComplete. (Added at v3.5)
Event Object Properties:
<FeatureSet> featureSet The FeatureSet returned from the query.

query-ids-complete

Fires when queryIds() is complete. Should be used in favor of onQueryIdsComplete. (Added at v3.5)
Event Object Properties:
<Number[]> objectIds Array of ObjectIds returned from the query.

query-limit-exceeded

Fired when the feature layer could not draw all the features due to a maxRecordCount limitation on a query operation. Should be used in favor of onQueryLimitExceeded. (Added at v3.5)

refresh-interval-change

This event is fired when the layer's refreshInterval is modified. (Added at v3.7)

resume

Fires when a layer resumes drawing. (Added at v3.6)

scale-range-change

Fires when a layer's minScale and/or maxScale is changed. Should be used in favor of onScaleRangeChange. (Added at v3.5)

scale-visibility-change

Fires when a layer's scale visibility changes. The scale visibility changes when a layer is initially visible and becomes invisible because the map scale does not intersect the layer's scale range or vice versa. Should be used in favor of onScaleVisibilityChange. (Added at v3.5)

selection-clear

Fires after clearSelection has been called. Should be used in favor of onSelectionClear. (Added at v3.5)

selection-complete

Fires when selectFeatures() completes. Should be used in favor of onSelectionComplete. (Added at v3.5)
Event Object Properties:
<Graphic[]> features Features returned from the query. This does not equal the current selection, call getSelectedFeatures() to retrieve the current selection set.
<Number> method Selection method used in the selectFeatures method.

show-labels-change

Fired when the feature layer's labels are changed. Should be used in favor of onShowLabelsChange. (Added at v3.11)

suspend

Fires when a layer suspends drawing. (Added at v3.6)

update

Fires any time a layer has finished loading or updating itself. For an ArcGISTiledMapServiceLayer, the event fires when all required tiles have been retrieved and displayed. For an ArcGISDynamicMapServiceLayer or ArcGISImageServiceLayer, the event fires when the map image has been retrieved and displayed. For a GraphicsLayer, the event fires when all graphics have been redrawn after a pan or zoom. Deprecated at v2.0. Use update-start and update-end instead. (Added at v3.6)

update-end

Fired when the layer has finished updating its content. This event is always preceded by update-start. Should be used in favor of onUpdateEnd. (Added at v3.5)
Event Object Properties:
<Error> error Optional argument available when an error occurs during the update.
<Object> info Optional object that may have a boolean queryLimitExceeded property. queryLimitExceeded will be true if the feature layer could not draw all features due to a maxRecordCount limitation on the query operation. As of v2.8

update-start

Fired when the layer begins to update its content. The following table describes when the event is fired in various modes.
Snapshot
  • When the layer is added to the map.
  • When layer properties such as definition expression, time definition or time offset are modified.
  • When the map's time extent changes.
  • When the layer is refreshed.
OnDemand
  • When the layer is added to the map.
  • When the map's spatial extent or time extent changes.
  • When layer properties such as definition expression or time offset are modified.
  • When the layer is refreshed.
Selection The event is not fired in selection mode.
(Added at v3.6)

visibility-change

Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer. Should be used in favor of onVisibilityChange. (Added at v3.5)
Event Object Properties:
<Boolean> visible Fires when the layer visibility changes. A boolean property named visible indicates whether or not the layer is visible after visibility changed.
Show Modal