require(["esri/layers/DataAdapterFeatureLayer"], function(DataAdapterFeatureLayer) { /* code goes here */ });
Description
(Added at v3.12)
(Currently in beta)
Display features using data that contains location information such as X and Y coordinates, Street address, place names etc using a DataAdapter object to retrieve the features and a LocationProvider to generate their geometries.
While extending the FeatureLayer class, DataAdapterFeatureLayer behaves differently from FeatureLayer. It has the following behavior:
- Edits are applied on the client not posted to the server.
- Does not support queries that need to be performed on the server, e.g., queries with a where clause or non-extent based spatial queries.
Samples
Search for
samples that use this class.
Class hierarchy
esri/layers/Layer
|_esri/layers/GraphicsLayer
|_esri/layers/FeatureLayer
|_esri/layers/DataAdapterFeatureLayer
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. |
dataAdapter | Object | The DataAdapter object points to data sources that contain non-spatial tables. |
dataAdapterQuery | Object | The query parameters to use for the DataAdapter. |
dataAttributes | String[] | List of attribute fields added as custom data attributes to graphics node. |
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. |
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. |
locationProvider | LocationProviderBase | An instance of the Location Provider class. |
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. |
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. |
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. |
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.
Constructor Details
Creates a DataAdapterFeatureLayer.
Parameters:
<Object > dataAdapter |
Required |
The DataAdapter object. |
<Object > options |
Required |
Optional parameters used to create the layer. See options descriptions for further information. |
options
properties:
<Object > dataAdapterQuery |
Required |
The query parameters to use in retrieving the data through the DataAdapter. See the object specifications table for below for the structure of the dataAdapterQuery object. |
<LocationProviderBase > locationProvider |
Required |
An instance of the LocationProvider class. |
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.
The DataAdapter object points to data sources that contain non-spatial tables. This object is used to query tables for data that contains some geographic location.
Object Specifications: <dataAdapter
>
<Promise > getTableInfo(tableId:String) |
Required |
Returns metadata (fields, data types, etc.) of a table. |
<Promise > getTables() |
Required |
Returns an array of tables. |
<Promise > query(options:Object) |
Required |
Executes a query on a table and returns records based on the options. The options property is defined by the dataAdapterQuery object, which identifies the tableId and outFields properties to use in the query. |
Sample:
var dataAdapter = {
getTableInfo: function(tableId: String){
//Return metadata for table based on the passed tableId
var deferred = new Deferred();
if (tableId == "SalesList") {
deferred.resolve({
label: "Sales"
idField: "id",
fields: [{...}]
});
} else {
deferred.error("Table not found!");
}
return deferred.promise;
},
getTables: function (){
//return an array of Tables...
var tables = [{
id: "Customers",
label: "Customer List"
}, {
id: "Leads",
label: "Potential Customer Leads"
}];
var deferred = new Deferred();
deferred.resolve(tables);
return deferred.promise;
},
query: function (options: Object) {
//options Object contains tableId that should queried and outFields that query should return
// { tableId: "SalesList",
// outFields: ["Customer Name", "Address", "Order Qty", "Total Sales"]
// }
var def = new Deferred();
if (options.tableId == "SalesList"){
deferred.resolve({
features: [{..}]
});
} else {
deferred.error ("Table does not exist!")
}
return deferred.promise;
}
};
The query parameters to use for the DataAdapter.
Object Specifications: <dataAdapterQuery
>
<String > outFields |
Required |
The fields for the query to return. |
<String > tableId |
Required |
The tableID on which to perform the query. |
List of attribute fields added as custom data attributes to graphics node.
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.
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
An instance of the Location Provider class.
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. (Added at v3.7)
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
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
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".
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.
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 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) {
});
...
});
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)
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 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. |
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 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 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. |