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
Properties
advancedQueryCapabilities | Object | 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. |
allowUpdateWithoutMValues | Boolean | Indicates whether attribute features containing m-values can be edited. |
capabilities | String | Information about the capabilities enabled for this layer. |
className | String | class attribute of the layer's node. |
columnDelimiter | String | The column delimiter. |
copyright | String | 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. |
dataAttributes | String | String[] | List of attribute fields added as custom data attributes to graphics node. |
defaultDefinitionExpression | String | Metadata describing the default definition expression for the layer as defined by the service. |
defaultVisibility | Boolean | Indicates the default visibility for the layer. |
description | String | The description of the layer as defined in the map service. |
displayField | String | The name of the layer's primary display field. |
editingInfo | Object | Applicable to ArcGIS Online hosted feature services. |
fields | Field[] | The array of fields in the layer. |
fullExtent | Extent | The full extent of the layer. |
geometryType | String | Geometry type of the features in the layer. |
graphics | Graphic[] | Array of features in the layer. |
hasAllFeatures | Boolean | Indicates whether the layer displays all features intersecting the current view. |
htmlPopupType | String | The html popup type defined for the layer. |
id | String | ID assigned to the layer. |
infoTemplate | InfoTemplate | The info template for the layer. |
labelingInfo | LabelClass[] | Label definition for this layer, specified as an array of label classes. |
latitudeFieldName | String | The latitude field name. |
layerId | Number | Unique ID of the layer that the FeatureLayer was constructed against. |
loadError | Error | Set if the layer failed to load. |
loaded | Boolean | When the layer is loaded, the value becomes "true", and layer properties can be accessed. |
longitudeFieldName | String | The longitude field name. |
maxAllowableOffset | Number | The maximum allowable offset, only applicable for layers that are not editable. |
maxScale | Number | Maximum visible scale for the layer. |
minScale | Number | Minimum visible scale for the layer. |
multipatchOption | String | Supports feature services whose data source is a multipatch featureclass.
- Default is
xyFootprint if geometryType is esriGeometryMultiPatch . |
name | String | The name of the layer as defined in the map service. |
objectIdField | String | The name of the field that contains the Object ID field for the layer. |
opacity | Number | Opacity or transparency of layer. |
refreshInterval | Number | Refresh interval of the layer in minutes. |
renderer | Renderer | The renderer for the layer. |
showAttribution | Boolean | When true, the layer's attribution is displayed on the map. |
showLabels | Boolean | Determines if labels are displayed. |
source | LayerSource | The dynamic layer or table source. |
styling | Boolean | Indicates whether the layer is responsible for styling graphics. |
supportsFieldDescription | Boolean | If true, the layer supports a user-defined field description. |
surfaceType | String | Type of vector graphics surface used to draw graphics. |
suspended | Boolean | When true, the layer is suspended. |
templates | FeatureTemplate[] | An array of feature templates defined in the Feature Service layer. |
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. |
type | String | Specifies the type of layer. |
url | String | The url to a CSV resource. |
version | Number | The version of ArcGIS Server where the layer is published. |
visible | Boolean | Visibility of the layer. |
visibleAtMapScale | Boolean | When true, the layer is visible at the current map scale. |
webglEnabled | Boolean | Indicates if WebGL is enabled on the layer. |
Methods
add(graphic) | Graphic | Adds a graphic. |
attr(name, value) | Layer | Adds a new attribute or changes the value of an existing attribute on the layer's node. |
clear() | None | Clears all graphics. |
clearSelection() | FeatureLayer | Clears the current selection. |
disableFeatureReduction() | None | Disables feature reduction (for example clustering) on the layer. |
disableMouseEvents() | None | Disables all mouse events on the graphics layer. |
enableFeatureReduction() | None | Enables feature reduction (for example clustering) on the layer using the options set in setFeatureReduction(). |
enableMouseEvents() | None | Enables all mouse events on the graphics layer. |
getAggregateGraphics() | Graphic[] | Returns graphics representing the aggregation of several point features clustered together. |
getDefinitionExpression() | String | Returns the current definition expression. |
getDomain(fieldName, options?) | Domain | Returns the Domain associated with the given field name. |
getEditCapabilities(options?) | Object | Returns an object that describes the edit capabilities of the layer. |
getFeatureReduction() | Object | Returns the options used to reduce the number of features visualized by the layer (for example clustering). |
getField(fieldName) | Field | Returns the Field given the specified field name. |
getMap() | Map | Returns reference to the map control the layer is added to. |
getMaxAllowableOffset() | Number | Returns the current value of the maxAllowableOffset used by the layer. |
getNode() | HTMLElement | Returns 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() | Symbol | Gets 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() | TimeExtent | Get the current time definition applied to the feature layer. |
getType(feature) | FeatureType | Returns a FeatureType describing the feature's type. |
hasUpdateError() | None | Indicates whether an error is thrown after the layer updates. |
hasWebGLSurface() | Boolean | Indicates if the layer is rendered in WebGL. |
hasXYFootprint() | Boolean | Returns true if geometryType is esriGeometryMultipatch and multipatchOption is xyFootprint . |
hide() | None | Sets the visibility of the layer to "false". |
isEditable() | Boolean | Returns true if the FeatureLayer is editable. |
isFeatureReductionActive() | Boolean | Indicates if feature reduction (for example clustering) is active in the view. |
isFeatureReductionEnabled() | Boolean | Indicates if feature reduction (for example clustering) is enabled. |
isVisibleAtScale(scale) | Boolean | Returns true if the layer is visible at the given scale. |
queryAttachmentInfos(objectId, callback?, errback?) | Deferred | Query for information about attachments associated with the specified ObjectIds. |
queryCount(query, callback?, errback?) | Deferred | Get a count of the number of features that satisfy the input query. |
queryExtent(query, callback?, errback?) | Deferred | Get the extent of features that satisfy the input query. |
queryFeatures(query, callback?, errback?) | Deferred | Query features from the feature layer. |
queryIds(query, callback?, errback?) | Deferred | Query for ObjectIds. |
queryRelatedFeatures(relQuery, callback?, errback?) | Deferred | Query features or records, from another layer or table, related to features in this layer. |
redraw() | None | Redraws all the graphics in the graphics layer. |
refresh() | None | Refreshes the features in the feature layer. |
remove(graphic) | Graphic | Removes a graphic. |
resume() | None | Resumes layer drawing. |
selectFeatures(query, selectionMethod?, callback?, errback?) | Deferred | Selects features from the FeatureLayer. |
setAutoGeneralize(enable) | FeatureLayer | Enable or disable auto generalization for the layer. |
setDefinitionExpression(expression) | FeatureLayer | Sets the definition expression for the FeatureLayer. |
setEditable(editable) | FeatureLayer | Set the editability of feature layers created from a feature collection. |
setFeatureReduction(options) | None | Sets feature reduction options on the layer (for example clustering options). |
setInfoTemplate(infoTemplate) | None | Specify or change the info template for a layer. |
setLabelingInfo(labelingInfo) | None | Sets labeling info on the layer. |
setMaxAllowableOffset(offset) | None | Sets the maximum allowable offset used when generalizing geometries. |
setMaxScale(scale) | None | Set the maximum scale for the layer. |
setMinScale(scale) | None | Set the minimum scale for the layer. |
setOpacity(opacity) | None | Initial opacity or transparency of layer. |
setRefreshInterval(interval) | Layer | Changes the layer's refresh interval to the given value (in minutes). |
setRenderer(renderer) | None | Set the renderer for the feature layer. |
setScaleRange(minScale, maxScale) | None | Set the scale range for the layer. |
setSelectionSymbol(symbol) | FeatureLayer | Sets the selection symbol for the feature layer. |
setShowLabels(showLabels) | None | Sets whether to display labels or not. |
setTimeDefinition(definition) | FeatureLayer | Sets the time definition for the feature layer. |
setTimeOffset(offsetValue, offsetUnits) | FeatureLayer | 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. |
setUseMapTime(update) | None | Determine if the layer will update its content based on the map's current time extent. |
setVisibility(isVisible) | None | Sets the visibility of the layer. |
setWebGLEnabled(enable) | None | Toggles WebGL rendering on/off on the layer. |
show() | None | Sets the visibility of the layer to "true". |
suspend() | None | Suspends layer drawing. |
toJson() | Object | Returns 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.
Constructor Details
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
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} */
});
Indicates whether attribute features containing m-values can be edited. (Added at v3.21)
Default value: false
Information about the capabilities enabled for this layer.
class attribute of the layer's node.
(Added at v3.7)
Copyright information for the layer.
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)
List of attribute fields added as custom data attributes to graphics node. Applicable only when layer surfaceType
is "svg"
. (Added at v3.7)
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'".
Indicates the default visibility for the layer. (Added at v3.0)
Known values: true | false
Sample:
var isVisible = layer.defaultVisibility;
The description of the layer as defined in the map service.
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.
Applicable to ArcGIS Online hosted feature services. If present, this object specifies information about editing. See the object specifications table below for the structure of the editingInfo object. (Added at v3.28)
Object Specifications: <editingInfo
>
<Number > lastEditDate |
Required |
A read-only value that indicates the last time a layer was edited. This value gets updated every time the layer data is edited or when any of the layer properties change. The value is depicted as a Unix timestamp, e.g.
"editingInfo" : {
"lastEditDate" : 1536363634886
}
|
The array of fields in the layer.
The full extent of the layer.
Geometry type of the features in the layer. Can be one of the following: "esriGeometryPoint", "esriGeometryPolygon" or "esriGeometryPolyline".
Array of features in the layer.
Indicates whether the layer displays all features intersecting the current view. Typically, this method should be called after the layer emits the
update-end
event.
(Added at v3.28) Default value: true
The html popup type defined for the layer. View the constants table for a list of valid values.
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);
}
}
The info template for the layer. (Added at v3.9)
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
}]
Unique ID of the layer that the FeatureLayer was constructed against.
Set if the layer failed to load. (Added at v3.9)
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
The longitude field name.
The maximum allowable offset, only applicable for layers that are not editable. (Added at v2.7)
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
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
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);
The name of the layer as defined in the map service.
The name of the field that contains the Object ID field for the layer.
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
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
The renderer for the layer.
When true, the layer's attribution is displayed on the map. (Added at v3.1)
Known values: true | false
Default value: true
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
The dynamic layer or table source. (Added at v2.7)
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
If true, the layer supports a user-defined field description. Please see the ArcGIS Online help topic,
Describe attribute fields for additional information.
(Added at v3.28)
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.
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
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);
});
...
});
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.
Specifies the type of layer. Can be "Feature Layer" or "Table".
The url to a CSV resource.
The version of ArcGIS Server where the layer is published. Examples are 9.3, 9.31, 10. (Added at v2.1)
Visibility of the layer.
Known values: true | false
Default value: true
When true, the layer is visible at the current map scale. (Added at v3.1)
Known values: true | false
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
Adds a graphic. It is not recommended to call
add()
on a
FeatureLayer as the layer automatically manages fetching (from the service) and clearing graphics based on its
mode. Additional graphics added to the layer by calling
add()
may be lost during this process. For feature layers, we recommend using
applyedits() to add, delete, and update features.
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));
}
...
});
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)
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. |
Clears all graphics. It is not recommended to call
clear()
on a
FeatureLayer as the layer automatically manages fetching (from the service) and clearing graphics based on its
mode. Explicitly calling
clear()
to clear the graphics will interfere with the integrity of this process. For feature layers, we recommend using
applyedits() to add, delete, and update features.
Sample:
graphicsLayer.clear();
Clears the current selection.
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();
Disables all mouse events on the graphics layer.
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();
Enables all mouse events on the graphics layer.
Returns graphics representing the aggregation of several point features clustered together. Only applicable when
feature reduction is
enabled.
(Added at v3.22) Sample:
var aggregateGraphics = featureLayer.getAggregateGraphics();
Returns the current definition expression.
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. |
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) 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");
}
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) Sample:
featureLayer.getFeatureReduction();
Returns the
Field
given the specified field name.
(Added at v3.12) Parameters:
<String > fieldName |
Required |
Name of the attribute field. |
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)
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)
Sample:
var currentOffset = featureLayer.getMaxAllowableOffset();
Returns the layer's DOM node. (Added at v3.7)
Returns the list of fields used to order features by. For queries as well as rendering. (Added at v3.8)
Gets the currently selected features.
Gets the current selection symbol.
Returns graphics from the layer that are not represented by aggregate graphics when feature reduction (such as clustering) is
enabled.
(Added at v3.22) Sample:
var singleGraphics = featureLayer.getSingleGraphics();
Get the current time definition applied to the feature layer.
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);
...
});
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) Parameters:
<Graphic > feature |
Required |
A feature from this layer. |
Indicates whether an error is thrown after the layer updates. (Added at v3.24)
Indicates if the layer is rendered in WebGL. (Added at v3.24)
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) Sample:
citiesFeatureLayer.on("load", function featureLayerLoaded(event){
var hasXYFootprint = citiesFeatureLayer.hasXYFootprint();
console.log("Contains xyfootprints:", hasXYFootprint);
});
Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.
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.
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) Sample:
featureLayer.isFeatureReductionActive();
Indicates if feature reduction (for example clustering) is enabled. Only applicable to point layers. See also
setFeatureReduction().
(Added at v3.22) Sample:
featureLayer.isFeatureReductionEnabled();
Returns true if the layer is visible at the given scale. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The scale at which to check if the layer is visible. |
Query for information about attachments associated with the specified ObjectIds.
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. |
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)
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);
});
...
});
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)
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. |
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.
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) {
});
...
});
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.
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
});
...
});
Query features or records, from another layer or table, related to features in this layer.
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);
}
...
});
Redraws all the graphics in the graphics layer. Unlike refresh(), redraw does not re-query features from the server. (Added at v3.3)
Refreshes the features in the feature layer. The feature layer requeries all the features in the service, except the selected features, and updates itself.
Removes a graphic. It is not recommended to call
remove()
on a
FeatureLayer as the layer automatically manages fetching (from the service) and clearing graphics based on its
mode. Explicitly calling
remove()
to remove the graphics will interfere with the integrity of this process. For feature layers, we recommend using
applyedits() to add, delete, and update features.
Parameters:
<Graphic > graphic |
Required |
The graphic to remove. |
Resumes layer drawing. (Added at v3.1)
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).
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);
...
});
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)
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);
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.
Parameters:
<String > expression |
Required |
The definition expression to apply. For example, "TYPE='Park'" |
Sample:
featureLayer.setDefinitionExpression("STATE_NAME = 'South Carolina'");
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) Parameters:
<Boolean > editable |
Required |
When true, the layer will be set as editable. |
Sample:
featureLayer.setEditable(true);
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
});
Specify or change the info template for a layer. (Added at v2.2)
Sample:
require([
"esri/InfoTemplate", ...
], function(InfoTemplate, ... ) {
var template = new InfoTemplate();
template.setTitle("${qAddress}");
template.setContent(getTextContent);
featureLayer.setInfoTemplate(template);
...
});
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 ]);
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
});
...
});
Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The maximum scale at which the layer is visible. |
Set the minimum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The minimum scale at which the layer is visible. |
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);
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)
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. |
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);
...
});
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);
Sets the selection symbol for the feature layer. If no symbol is specified, features are drawn using the layer's renderer.
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);
...
});
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. |
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
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);
...
});
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).
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. |
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. |
Sets the visibility of the layer. When true, the layer is visible.
Parameters:
<Boolean > isVisible |
Required |
Set the visibility of the layer. |
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);
Sets the visibility of the layer to "true".
Suspends layer drawing. (Added at v3.1)
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[]>
}
}
Event Details
[ On Style Events | Connect Style Event ]
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. |
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);
});
...
});
Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
Fired when the geodatabase version is switched. (Added at v3.5)
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. |
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(). |
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)
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)
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. |
Fires when all graphics in the GraphicsLayer are cleared. Should be used in favor of onGraphicsClear. (Added at v3.5)
Fired when labeling info on the layer changes. (Added at v3.10)
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. |
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)
Fires while the mouse is being dragged until the mouse button is released. Should be used in favor of onMouseDrag. (Added at v3.5)
Fires as the mouse moves through a graphic on the GraphicsLayer. Should be used in favor of onMouseMove. (Added at v3.5)
Fires as the mouse exits a graphic on the GraphicsLayer. Should be used in favor of onMouseOut. (Added at v3.5)
Fires when the mouse first enters into a graphic on the GraphicsLayer. Should be used in favor of onMouseOver. (Added at v3.5)
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)
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. |
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. |
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. |
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. |
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. |
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)
This event is fired when the layer's refreshInterval
is modified. (Added at v3.7)
Fires right before the actual refresh kicks in for the layer, and only fires when the refresh is triggered by the
refreshInterval.
(Added at v3.27)
Fires when a layer resumes drawing. (Added at v3.6)
Fires when a layer's minScale and/or maxScale is changed. Should be used in favor of onScaleRangeChange. (Added at v3.5)
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)
Fires after clearSelection has been called. Should be used in favor of onSelectionClear. (Added at v3.5)
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. |
Fired when the feature layer's labels are changed. Should be used in favor of onShowLabelsChange. (Added at v3.11)
Fires when a layer suspends drawing. (Added at v3.6)
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 |
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)
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. |
Fires when a graphic has been clicked.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when a feature has been double clicked.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and graphic. |
Sample:
dojo.connect(firePerimeterFL, "onDblClick", function(evt) {
editToolbar.activate(esri.toolbars.Edit.EDIT_VERTICES , evt.graphic);
});
Fires when there is a problem retrieving a layer. (Added at v1.3)
Fires when a graphic is added to the GraphicsLayer.
Event Object Properties:
<Graphic > graphic |
The added graphic. |
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:
<Object > evt |
The < Graphic > graphic being drawn. When the layer surfaceType is "svg" or "vml" , the graphic's DOM node is accessible with graphic.getNode() . |
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:
<Object > evt |
An object with the following properties:
- < Graphic > graphic:Graphic being drawn.
- < DOM Node > node: Graphic's DOM Node.
|
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:
<Object > evt |
An object with the following properties:<Graphic> graphic | Graphic being drawn. | <DOM Node> node | Graphic's DOM node. |
|
Fires when a graphic is removed from the GraphicsLayer.
Event Object Properties:
<Graphic > graphic |
The removed graphic. |
Fires when all graphics in the GraphicsLayer are cleared.
Fired when labeling info on the layer changes. (Added at v3.10)
Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map.
In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the onLoad event:
Event Object Properties:
<Layer > layer |
The loaded layer. |
Sample: function init() {
//setting initial extent in constructor
var map = new esri.Map("mapDiv", { extent: new esri.geometry.Extent(...) });
//or use set extent method
var map = new esri.Map("mapDiv");
map.setExtent(new esri.geometry.Extent(...));
//add first layer
map.addLayer(...);
}
Fires when a mouse button is pressed down and the mouse cursor is on a graphic.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires while the mouse is being dragged until the mouse button is released.
Event Object Properties:
<Object > event |
The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires as the mouse moves through a graphic on the GraphicsLayer.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires as the mouse exits a graphic on the GraphicsLayer.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when the mouse first enters into a graphic on the GraphicsLayer.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when a mouse button is released and the mouse cursor is on a graphic.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when the layer opacity has been changed, and returns the opacity value.
Event Object Properties:
<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. |
Fires when the query for the count is complete. This event is only available for layers published using ArcGIS Server 10 SP1 or later. (Added at v2.1)
Event Object Properties:
<Number > count |
The number of features that satisfy the input query. |
Sample:
dojo.connect(featureLayer,'onQueryCountComplete',function(count){
console.log(count + " features satisfied the input query");
});
Fires when queryExtent method has completed. (Added at v3.9)
Event Object Properties:
<Extent > extent |
The extent of features. |
<Number > count |
The count of features. |
Fires when queryFeatures() is complete.
Event Object Properties:
<FeatureSet > featureSet |
The FeatureSet returned from the query. |
Fires when queryIds() is complete.
Event Object Properties:
<Number[] > ids |
Array of ObjectIds returned from the query. |
Fired when the feature layer could not draw all the features due to a maxRecordCount
limitation on a query operation. (Added at v2.8)
This event is fired when the layer's refreshInterval
is modified. (Added at v3.7)
Fires when a layer resumes drawing. (Added at v3.1)
Fires when a layer's minScale and/or maxScale is changed. (Added at v3.1)
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. (Added at v3.1)
Fires after clearSelection has been called.
Fires when selectFeatures() has completed. OnSelectionComplete always fires unless there is an error returned by the server.
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 > selectionMethod |
Selection method used in the selectFeatures method. |
Fires when the labels of the featurelayer have changed. (Added at v3.11)
Fires when a layer suspends drawing. (Added at v3.1)
Fired when the layer has finished updating its content. This event is always preceded by onUpdateStart
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 |
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.
|
Fires when the layer visibility has been changed, and returns the new visibility.
Event Object Properties:
<Boolean > visbility |
Determines whether the layer is visible on the map. |