require(["esri/layers/StreamLayer"], function(StreamLayer) { /* code goes here */ });
Description
(Added at v3.6)
The stream layer extends the feature layer to add the ability to connect to a stream of data using HTML5 WebSockets. It connects to a server that emits geographic features continuously. While the feature layer is used to map relatively static data, the stream layer is suitable when you would like to map dynamic streams of data that are unbounded and continuous. When a stream layer is added to a map, users are able to see any real-time updates pushed out by the server.
A real-time-enabled data server is required in order to use this class. The
ArcGIS GeoEvent Processor for Server is a tool you may use to set up and configure your data stream. In addition, version 10.3 of ArcGIS GeoEvent Extension for Server exposes stream services. To learn more about this, please see the
Stream Services documentation.
You may also use your own web socket server, as long as it emits geographic features in the
Esri JSON format.
The number of features coming from a real-time feed can overload the browser and make the browser unresponsive. Use the
purgeOptions
construction option to define rules that specify how to remove data when new messages are received and the layer is refreshed.
NOTE: WebSockets are a feature of HTML5. Most browsers are supporting WebSockets in recent versions. However, they are not supported by all versions of all browsers. To get more information about WebSockets and to test if a browser supports WebSockets, visit
WebSocket.org.
Samples
Search for
samples that use this class.
Class hierarchy
esri/layers/Layer
|_esri/layers/GraphicsLayer
|_esri/layers/FeatureLayer
|_esri/layers/StreamLayer
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. |
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. |
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. |
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. |
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. |
maxAllowableOffset | Number | The maximum allowable offset, only applicable for layers that are not editable. |
maxScale | Number | Maximum visible scale for the layer. |
maximumTrackPoints | Number | The maximum number of observations being shown for each unique track. |
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. |
purgeInterval | Number | Purge 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. |
socket | Object | Raw access to the connected websocket. |
socketUrl | String | URL used to make the socket connection. |
source | LayerSource | The dynamic layer or table source. |
styling | Boolean | Indicates whether the layer is responsible for styling graphics. |
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 | URL to the ArcGIS Server REST resource that represents a map service. |
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
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
attempt-reconnect | {
count: <Number >,
url: <String >
} | Fires when the layer attempts to reconnect to the web socket. |
click | {
event: <Object >
} | Fires when a graphic has been clicked. |
connect | | Fires when connection is successfully made to socket. |
connection-error | {
error: <Error >
} | Fires when a connection cannot be made with the web socket. |
dbl-click | {
event: <Object >
} | Fires when a feature has been double clicked. |
disconnect | | Fires when disconnect from socket. |
error | {
error: <Error >
} | Fires when there is a problem retrieving a layer. |
filter-change | {
error: <Error >,
filter: <Object >
} | Fires when the layer receives a message that the server-side filter has been changed. |
gdb-version-change | | Fired 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-clear | | Fires when all graphics in the GraphicsLayer are cleared. |
labeling-info-change | | Fired when labeling info on the layer changes. |
load | {
layer: <Layer >
} | Fires after layer properties for the layer are successfully populated. |
message | {
message: <Object >
} | Fires after a message is pushed to the layer. |
mouse-down | <MouseEvent > mouseEvent | Fires when a mouse button is pressed down and the mouse cursor is on a graphic. |
mouse-drag | <MouseEvent > mouseEvent | Fires while the mouse is being dragged until the mouse button is released. |
mouse-move | <MouseEvent > mouseEvent | Fires as the mouse moves through a graphic on the GraphicsLayer. |
mouse-out | <MouseEvent > mouseEvent | Fires as the mouse exits a graphic on the GraphicsLayer. |
mouse-over | <MouseEvent > mouseEvent | Fires when the mouse first enters into a graphic on the GraphicsLayer. |
mouse-up | <MouseEvent > mouseEvent | Fires 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. |
purge-interval-change | | Fires when the purgeInterval property is changed. |
query-ids-complete | {
objectIds: <Number[] >
} | Fires when queryIds() is complete. |
query-limit-exceeded | | Fired when the feature layer could not draw all the features due to a maxRecordCount limitation on a query operation. |
resume | | Fires when a layer resumes drawing. |
scale-range-change | | Fires when a layer's minScale and/or maxScale is changed. |
scale-visibility-change | | Fires when a layer's scale visibility changes. |
selection-clear | | Fires after clearSelection has been called. |
selection-complete | {
features: <Graphic[] >,
method: <Number >
} | Fires when selectFeatures() completes. |
show-labels-change | | Fired when the feature layer's labels are changed. |
suspend | | Fires when a layer suspends drawing. |
update | {
graphic: <Graphic >
} | Fires any time a layer has finished loading or updating itself. |
update-end | {
error: <Error >,
info: <Object >,
relatedFeatureWarning: <String >
} | Fired when the layer has finished updating its content. |
update-start | | Fires when layer is added to map (if stream service is associated with an archive feature service) and when graphics are updated on the map due to new ones being added or removed (for example purged). |
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
Creates a new StreamLayer
with a service URL. (Added at v3.7)
Parameters:
<String > url |
Required |
URL to an ArcGIS Server Stream Service. Note: Applicable only when layer surfaceType is "svg" . For other surface types, this option is ignored. |
<Object > options |
Optional |
Optional parameters used to create the layer. See options descriptions for further information. |
options
properties:
<String > className |
Optional |
Class attribute to set for the layer's node. |
<String > definitionExpression |
Optional |
Where clause to use as definition expression for layer. Added at v3.11 |
<Extent > geometryDefinition |
Optional |
The extent to use as the spatial filter for the layer. Added at v3.11 |
<Number > maximumTrackPoints |
Optional |
Maximum number of observations to show for each unique track. Use 0 to show all observations, 1 to only show the most current observation for each track. A trackId field must be specified in the constructor parameters or in the Feature Collection. The default value is 1. |
<String[] > outFields |
Optional |
An array of strings corresponding with fields to include in the StreamLayer. You can specify ["*"] to fetch values for all fields in the layer. |
<Object > purgeOptions |
Optional |
Rules for purging data from the layer to avoid overloading the browser with too many features. You can purge based on the number of max features and/or the maximum time that a feature should display on the map. The expiration time is based either on the value of the field specified as the startTime field or the time the message is received. See the object specifications table below for the structure of the purgeOptions object.
When a message is received by the layer, expired features are removed and then features will be removed from the beginning of the graphics array if the total number of graphics in the layer exceeds the displayCount.
purgeOptions: {
displayCount: 2000,
age: 2.5
} |
Object Specifications: <purgeOptions
>
<Number > age |
Required |
The maximum time in minutes that a feature will be displayed. After the time is reached, the feature is removed from the layer. Added at 3.13. |
<Number > displayCount |
Required |
The maximum number of features the layer will contain. |
Creates a new StreamLayer
with a FeatureCollection
object.
Parameters:
<Object > featureCollectionObject |
Required |
A feature collection object. See the object specifications tables below for details. |
<Object > options |
Optional |
Optional parameters used to create the layer. See options list. |
options
properties:
<String > className |
Optional |
Class attribute to set for the layer's node. |
<Extent > geometryDefinition |
Optional |
The extent to use as the spatial filter for the layer. Added at v3.11 |
<Number > maximumTrackPoints |
Optional |
Maximum number of observations to show for each unique track. Use 0 to show all observations, 1 to only show the most current observation for each track. A trackId field must be specified in the constructor parameters or in the Feature Collection. The default value is 1. |
<String[] > outFields |
Optional |
An array of strings corresponding with fields to include in the StreamLayer. You can specify ["*"] to fetch values for all fields in the layer. |
<Object > purgeOptions |
Optional |
Rules for purging data from the layer to avoid overloading the browser with too many features. You can purge based on the number of max features and/or the maximum time that a feature should display on the map. The expiration time is based either on the value of the field specified as the startTime field or the time the message is received. See the object specifications table below for the structure of the purgeOptions object.
When a message is received by the layer, expired features are removed and then features will be removed from the beginning of the graphics array if the total number of graphics in the layer exceeds the displayCount.
purgeOptions: {
displayCount: 2000,
age: 2.5
} |
<String > socketUrl |
Optional |
The URL to use for connecting to a socket. |
Object Specifications: <featureCollectionObject
>
<Object > featureSet |
Required |
A collection of features. |
<Object > layerDefinition |
Required |
The structure is the same as the information returned by REST for a layer in a feature or map service. The minimum layer definition required to create a feature collection object depends on the required functionality, i.e. time, rendering etc. |
<purgeOptions
>
<NUmber > age |
Required |
The maximum time in minutes that a feature will be displayed. After the time is reached, the feature is removed from the layer. Added at 3.13. |
<Number > displayCount |
Required |
The maximum number of features the layer will contain. |
Sample: require(["esri/layers/StreamLayer", ... ], function(StreamLayer, ... ){
var layerDefinition = {
"geometryType": "esriGeometryPoint",
"fields": [{
name: "ObjectId",
type: "esriFieldTypeOID",
alias: "ObjectId"
}, {
name: "AltitudeFeet",
type: "esriFieldTypeDouble",
alias: "AltitudeFeet"
}, {
name: "ACID",
type: "esriFieldTypeString",
alias: "Aircraft ID"
}]
};
var featureCollection = {
layerDefinition: layerDefinition,
featureSet: null
};
var layer = new StreamLayer(featureCollection, {
socketUrl: "ws://ec2-54-224-125-57.compute-1.amazonaws.com:8080/faatrackinfo",
purgeOptions: {
displayCount: 1000
}
};
...
});
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.
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.
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 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
The maximum number of observations being shown for each unique track. 0 means all observations are being shown; 1 means only the most current, and more than 1 means that the most current is shown plus (maximum - 1) previous observations. (Added at v3.12)
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
Purge interval of the layer in minutes. A value of 0 indicates no purging. Purging of features is done based on the purgeOptions that were supplied when the layer was created. (Added at v3.13)
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
Raw access to the connected websocket. A developer can access the websocket to override the websocket's events.
For instance, a developer might want to override the websocket's
onmessage
event to determine if a new item needs to be added to a unique value renderer before the layer gets refreshed by adding a new feature. This property will be null until the layer is loaded so it should only be accessed after the layer's
onLoad
event is fired. To see what events a WebSocket fires look at
WebSocket.org About WebSockets.
Note: When a developer overrides the
onmessage
event, it is their responsibility to handle updating the layer with the message. Messages are expected to be in Esri JSON format and a message can contain an array of features.
Sample: //override websocket onmessage event
layer.on("Connect", function() {
console.log("CONNECTED SOCKET: ", layer);
setTimeout(function() {
layer.socket.onmessage = function(e) {
//parse json
var msgarray = JSON.parse(e.data);
msgarray = Array.isArray(msgarray) ? msgarray : [msgarray];
for (var i = 0; i < msgarray.length; i++){
//make graphic
var jsonFeature = msgarray[i];
var graphic = new Graphic();
var geom = jsonUtils.fromJson(jsonFeature.geometry);
graphic.setGeometry(geom);
graphic.setAttributes(jsonFeature.attributes);
graphic.setSymbol(sym);
layer.add(graphic);
}
};
}, 25);
});
URL used to make the socket connection. Read-only.
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
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 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.
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.
Sample:
graphicsLayer.clear();
Clears the current selection.
Connect to the Stream Server socket. This method is called internally with the provided socketUrl
in the constructor. Triggers the onConnect
event.
Parameters:
<Function > callback |
Optional |
The function to call when the method has completed. |
Disables all mouse events on the graphics layer.
Disconnect from the Stream Server socket. Triggers the onDisconnect
event.
Parameters:
<Function > callback |
Optional |
The function to call when the method has completed. |
Enables all mouse events on the graphics layer.
Gets the where
property of the layer's filter. Only relevant when data for the layer is coming from an ArcGIS Server Stream Service. (Added at v3.11)
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 the
Field
given the specified field name.
(Added at v3.12) Parameters:
<String > fieldName |
Required |
Name of the attribute field. |
Gets the spatial filter set on the layer. (Added at v3.11)
Gets the latest observation for each track in the layer. If the layer does not have a "trackId" field set, then all the graphics in the layer are returned. (Added at v3.14)
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 layer's DOM node. (Added at v3.7)
Gets the currently selected features.
Gets the current selection symbol.
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. |
Gets the unique values of the graphics (in the StreamLayer) based on the `fieldName` parameter. The return array of unique values is sorted in ascending order. An empty array is returned if no `fieldName` parameter is supplied or if the field does not exist in the layer. (Added at v3.12)
Parameters:
<String > fieldName |
Required |
Field to get the unique values from. |
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 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. |
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.
Parameters:
<Graphic > graphic |
Required |
The graphic to remove. |
Resumes layer drawing. (Added at v3.1)
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'");
Sets the spatial filter for the layer. (Added at v3.11)
Parameters:
<Extent > extent |
Required |
Limit the features in the StreamLayer by setting a bounding box. |
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 ]);
Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The maximum scale at which the layer is visible. |
Sets the maximumTrackPoints property for the layer. (Added at v3.11)
Parameters:
<Number > value |
Required |
The maximum track points for the layer. |
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 purge interval to the given value (in minutes). A value of 0 stops purging. (Added at v3.13)
Parameters:
<Number > interval |
Required |
The purge interval in minutes. |
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. |
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 the layer attempts to reconnect to the web socket. (Added at v3.11)
Event Object Properties:
<Number > count |
Number of connection attempts made. |
<String > url |
Web socket URL being used for attempting to connect. |
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 connection is successfully made to socket.
Fires when a connection cannot be made with the web socket. (Added at v3.11)
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 disconnect from socket.
Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
Fires when the layer receives a message that the server-side filter has been changed. (Added at v3.11)
Event Object Properties:
<Error > error |
An optional parameter whose value will be a standard JavaScript Error object if an error occurred. |
<Object > filter |
Current server-side filter, an object with "geometry" and "where" as in {geometry: esri.geometry.Extent, where: String} . |
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 after a message is pushed to the layer. This event is fired before the message has affected the layer's graphics.
Event Object Properties:
<Object > message |
The message object. It can be of type "create", "delete", or "update". |
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 purgeInterval property is changed. (Added at v3.13)
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)
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)
Event Object Properties:
<Graphic > graphic |
The graphic that was added, updated, or removed from the layer. |
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 |
<String > relatedFeatureWarning |
(Added at 3.15), optional argument describing if a filter could not be applied to a feature or map service with features related to the stream service. Message reads, "Querying related feature service using the current filter failed. All related features are displayed, and the filter is applied to the stream service only." |
Fires when layer is added to map (if stream service is associated with an archive feature service) and when graphics are updated on the map due to new ones being added or removed (for example purged). (Added at v3.11)
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 the layer attempts to reconnect to the web socket. (Added at v3.11)
Event Object Properties:
<Number > count |
Number of connection attempts made. |
<String > url |
Web socket URL being used for attempting to connect. |
Fires when a graphic has been clicked.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when connection is successfully made to socket.
Fires when a connection cannot be made with the web socket. (Added at v3.11)
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 disconnect from socket.
Fires when there is a problem retrieving a layer. (Added at v1.3)
Fires when the layer receives a message that the server-side filter has been changed. (Added at v3.11)
Event Object Properties:
<Object > filter |
Current server-side filter, an object with "geometry" and "where" as in {geometry: esri.geometry.Extent, where: String} . |
<Error > error |
An optional parameter whose value will be a standard JavaScript Error object if an error occurred. |
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 after a message is pushed to the layer. Note: this event is fired after the layer is refreshed. To intercept a message before the layer is updated, use the technique above to override the onmessage event of the layer's socket.
Event Object Properties:
<Object > message |
An object with message property.
- < String > type: Type of this message. The value is "create", "delete", or "update".
- < Graphic> graphic : The graphic that was added, updated, or removed from the layer.
|
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 purgeInterval property is changed. (Added at v3.13)
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)
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)
Event Object Properties:
<Object > message |
The < Graphic > graphic that was added, updated, or removed from the layer. |
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 |
Fires when layer is added to map (if stream service is associated with an archive feature service) and when graphics are updated on the map due to new ones being added or removed (for example purged). (Added at v3.11)
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. |