A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/en/javascript/jsapi/featurelayer-amd.html below:

FeatureLayer | API Reference | ArcGIS API for JavaScript 3.46

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

(Added at v2.0)

The feature layer inherits from the graphics layer and can be used to display features from a single layer in either a Map Service or Feature Service. The layer can be either a (spatial) layer or (non-spatial) table. The features in a feature layer can be edited if the

isEditable

method is true.

The FeatureLayer will, by default, use the drawing information from the server (requires ArcGIS Server 10 or above). For an example, see the simple renderer in the Drawing Info at https://www.example.com/argis/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0

WebGL rendering

Starting at version 3.24, you can opt in to render FeatureLayer with WebGL. This allows you to display more data in the map and update the visualization of features more rapidly. To enable WebGL rendering of FeatureLayer, paste the following script in your application prior to loading the ArcGIS API for JavaScript:

<script>
  var dojoConfig = {
    has: {
      "esri-featurelayer-webgl": 1
    }
  };
</script>

Once enabled globally for the app, WebGL can be toggled on/off using the API below:

Known Limitations

The following are current limitations of WebGL-rendered FeatureLayers subject to change in future releases. If any of these conditions are not met, then the layer will automatically switch from WebGL to SVG during the session.

Note that only the click event will fire when WebGL is enabled. All other events are not supported. FeatureLayer subclasses do not support WebGL rendering. Also note that modifying attributes, symbol, geometry and visibility of individual features in a WebGL-rendered layer will NOT have any effect.

Samples

Search for

samples

that use this class.

Class hierarchy
esri/layers/Layer
|_esri/layers/GraphicsLayer
  |_esri/layers/FeatureLayer
Subclasses Constructors Constants MODE_AUTO

Delegate to either on-demand or snapshot mode depending on the characteristics of the service. This is only applicable to hosted feature services.

If the total number of features in a layer are less than maxRecordCount and total vertexes is less than 250,000, snapshot mode is used. Otherwise, on-demand mode is used. The purpose behind this mode is to reduce server-side load. Instead of getting a small number of features with several requests (on-demand mode), get all features with a single request. This mode requires an additional request to complete before retrieving any features.

MODE_ONDEMAND

In on-demand mode, the feature layer retrieves features from the server when needed. This is based on the requirements defined in the following properties:

MODE_SELECTION

In selection mode, features are retrieved from the server only when they are selected. Features are available on the client only while they are selected. To work with selected features:

  1. Call the selectFeatures method.
  2. Listen for the onSelectionComplete event.
  3. Once onSelectionComplete fires, retrieve the selected features using the getSelectedFeatures method.

When editing feature layers in selection mode, you will need to add the map service associated with the feature service to the map as a dynamic map service. If you do not have the map service added as a dynamic map service then the changes will not be visible because once the edits are complete the feature is no longer selected.

MODE_SNAPSHOT In snapshot mode, the feature layer retrieves all the features from the associated layer resource and displays them as graphics on the client. Definition expressions and time definitions are honored. The features are retrieved once the feature layer is added to the map. After the onUpdateEnd event has fired, you can access the features using the graphics property of the layer or through selection and query operations. POPUP_HTML_TEXT The popup displays content in HTML/TEXT. POPUP_NONE No popup type defined. POPUP_URL The popup displays the contents of a URL. SELECTION_ADD Adds features to the current selection set. SELECTION_NEW Creates a new selection. SELECTION_SUBTRACT Removes features from the current selection. 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. allowGeometryUpdates Boolean Returns true if the geometry of the features in the layer can be edited, false otherwise. allowUpdateWithoutMValues Boolean Indicates whether attribute features containing m-values can be edited. attributionDataUrl String The URL, when available, where the layer's attribution data is stored. 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. editFieldsInfo Object Indicates the field names for the editor fields. editingInfo Object Applicable to ArcGIS Online hosted feature services. fields Field[] The array of fields in the layer. fullExtent Extent The full extent of the layer. gdbVersion String The geodatabase version. geometryType String Geometry type of the features in the layer. globalIdField String The globalIdField for the layer. graphics Graphic[] Array of features in the layer. hasAllFeatures Boolean Indicates whether the layer displays all features intersecting the current view. hasAttachments Boolean True if attachments are enabled on the feature layer. hasAttributionData Boolean When true, the layer has attribution data. 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. maxRecordCount Number The maximum number of results that will be returned from a query. 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. 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. ownershipBasedAccessControlForFeatures Object Indicates the ownership access control configuration. refreshInterval Number Refresh interval of the layer in minutes. relationships Object[] Each element in the array is an object that describes the layer's relationship with another layer or table. renderer Renderer The renderer for the layer. showAttribution Boolean When true, the layer's attribution is displayed on the map. showLabels Boolean Determines if labels are displayed. source LayerSource The dynamic layer or table source. styling Boolean Indicates whether the layer is responsible for styling graphics. supportsAdvancedQueries Boolean When true, the layer supports orderByFields in a query operation. supportsAttachmentsByUploadId Boolean When true, the layer supports uploading attachments with Uploads REST operation, which then can be used in the Add Attachment or Update Attachment REST operations. supportsCalculate Boolean When true, the layer supports the Calculate REST operation when updating features. supportsFieldDescription Boolean If true, the layer supports a user-defined field description. supportsStatistics Boolean When true, the layer supports statistical functions in query operations. 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. typeIdField String The field that represents the Type ID field. types FeatureType[] An array of sub types defined in the Feature Service 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 addAttachment(objectId, formNode, callback?, errback?) Deferred Add an attachment to the feature specified by the ObjectId. applyEdits(adds?, updates?, deletes?, callback?, errback?) Deferred Apply edits to the feature layer. attr(name, value) Layer Adds a new attribute or changes the value of an existing attribute on the layer's node. clearSelection() FeatureLayer Clears the current selection. deleteAttachments(objectId, attachmentIds, callback?, errback?) Deferred Delete one or more attachments for the feature specified by the input ObjectId. disableFeatureReduction() None Disables feature reduction (for example clustering) on the layer. disableMouseEvents() None Disables all mouse events on the graphics layer. enableFeatureReduction() None Enables feature reduction (for example clustering) on the layer using the options set in setFeatureReduction(). enableMouseEvents() None Enables all mouse events on the graphics layer. getAggregateGraphics() Graphic[] Returns graphics representing the aggregation of several point features clustered together. getAttributionData() Deferred Asynchrously returns custom data for the layer when available. getDefinitionExpression() String Returns the current definition expression. getDomain(fieldName, options?) Domain Returns the Domain associated with the given field name. getEditCapabilities(options?) Object Returns an object that describes the edit capabilities of the layer. getEditInfo(feature, options?) Object Returns an object describing the most recent edit operation performed on the given feature, if available. getEditSummary(feature, options?) String Returns a localized summary of the last edit operation performed on the given feature, if available. getFeatureReduction() Object Returns the options used to reduce the number of features visualized by the layer (for example clustering). getField(fieldName) Field Returns the Field given the specified field name. getMap() Map Returns reference to the map control the layer is added to. getMaxAllowableOffset() Number Returns the current value of the maxAllowableOffset used by the layer. getNode() HTMLElement Returns the layer's DOM node. getOrderByFields() String[] Returns the list of fields used to order features by. getSelectedFeatures() Graphic[] Gets the currently selected features. getSelectionSymbol() Symbol Gets the current selection symbol. getSingleGraphics() Graphic[] Returns graphics from the layer that are not represented by aggregate graphics when feature reduction (such as clustering) is enabled. getTimeDefinition() TimeExtent Get the current time definition applied to the feature layer. getType(feature) FeatureType Returns a FeatureType describing the feature's type. hasUpdateError() None Indicates whether an error is thrown after the layer updates. hasWebGLSurface() Boolean Indicates if the layer is rendered in WebGL. hasXYFootprint() Boolean Returns true if geometryType is esriGeometryMultipatch and multipatchOption is xyFootprint. hide() None Sets the visibility of the layer to "false". isEditable() Boolean Returns true if the FeatureLayer is editable. isFeatureReductionActive() Boolean Indicates if feature reduction (for example clustering) is active in the view. isFeatureReductionEnabled() Boolean Indicates if feature reduction (for example clustering) is enabled. isVisibleAtScale(scale) Boolean Returns true if the layer is visible at the given scale. queryAttachmentInfos(objectId, callback?, errback?) Deferred Query for information about attachments associated with the specified ObjectIds. queryCount(query, callback?, errback?) Deferred Get a count of the number of features that satisfy the input query. queryExtent(query, callback?, errback?) Deferred Get the extent of features that satisfy the input query. queryFeatures(query, callback?, errback?) Deferred Query features from the feature layer. queryIds(query, callback?, errback?) Deferred Query for ObjectIds. queryRelatedFeatures(relQuery, callback?, errback?) Deferred Query features or records, from another layer or table, related to features in this layer. redraw() None Redraws all the graphics in the graphics layer. refresh() None Refreshes the features in the feature layer. resume() None Resumes layer drawing. selectFeatures(query, selectionMethod?, callback?, errback?) Deferred Selects features from the FeatureLayer. setAutoGeneralize(enable) FeatureLayer Enable or disable auto generalization for the layer. setDefinitionExpression(expression) FeatureLayer Sets the definition expression for the FeatureLayer. setEditable(editable) FeatureLayer Set the editability of feature layers created from a feature collection. setFeatureReduction(options) None Sets feature reduction options on the layer (for example clustering options). setGDBVersion(versionName) FeatureLayer Set the layer's data source to the specified geodatabase version. setInfoTemplate(infoTemplate) None Specify or change the info template for a layer. setLabelingInfo(labelingInfo) None Sets labeling info on the layer. setMaxAllowableOffset(offset) None Sets the maximum allowable offset used when generalizing geometries. setMaxScale(scale) None Set the maximum scale for the layer. setMinScale(scale) None Set the minimum scale for the layer. setOpacity(opacity) None Initial opacity or transparency of layer. setRefreshInterval(interval) Layer Changes the layer's refresh interval to the given value (in minutes). setRenderer(renderer) None Set the renderer for the feature layer. setScaleRange(minScale, maxScale) None Set the scale range for the layer. setSelectionSymbol(symbol) FeatureLayer Sets the selection symbol for the feature layer. setShowLabels(showLabels) None Sets whether to display labels or not. setTimeDefinition(definition) FeatureLayer Sets the time definition for the feature layer. setTimeOffset(offsetValue, offsetUnits) FeatureLayer Time offset allows you to display the features at a different time so they can be overlaid on top of previous or future time periods. setUseMapTime(update) None Determine if the layer will update its content based on the map's current time extent. setVisibility(isVisible) None Sets the visibility of the layer. setWebGLEnabled(enable) None Toggles WebGL rendering on/off on the layer. show() None Sets the visibility of the layer to "true". suspend() None Suspends layer drawing. toJson() Object Returns an easily serializable object representation of the layer. Events

[ On Style Events | Connect Style Event ]

All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events add-attachment-complete
{
  result: <FeatureEditResult>
}
Fires when addAttachments() is complete. before-apply-edits
{
  adds: <Graphic[]>,
  deletes: <Graphic[]>,
  updates: <Graphic[]>
}
Fired before edits are applied to the feature layer. capabilities-change Fired when the capabilities of the layer are modified using the setEditable method. click
{
  event: <Object>
}
Fires when a graphic has been clicked. dbl-click
{
  event: <Object>
}
Fires when a feature has been double clicked. delete-attachments-complete
{
  results: <Object[]>
}
Fires when deleteAttachments is complete. edits-complete
{
  adds: <FeatureEditResult[]>,
  deletes: <FeatureEditResult[]>,
  updates: <FeatureEditResult[]>
}
Fires after applyEdits() is complete. error
{
  error: <Error>
}
Fires when there is a problem retrieving a layer. 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. 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. query-attachment-infos-complete
{
  info: <Object[]>
}
Fires when queryAttachmentInfos method is called. query-count-complete
{
  count: <Number>
}
Fires when the query for the count is complete. query-extent-complete
{
  count: <Number>,
  extent: <Extent>
}
Fires when queryExtent method has completed. query-features-complete
{
  featureSet: <FeatureSet>
}
Fires when queryFeatures() is complete. query-ids-complete
{
  objectIds: <Number[]>
}
Fires when queryIds() is complete. query-limit-exceeded Fired when the feature layer could not draw all the features due to a maxRecordCount limitation on a query operation. query-related-features-complete
{
  relatedFeatures: <Object>
}
Fires when queryRelatedFeatures() is complete. refresh-interval-change This event is fired when the layer's refreshInterval is modified. refresh-tick Fires right before the actual refresh kicks in for the layer, and only fires when the refresh is triggered by the refreshInterval. 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 Fires any time a layer has finished loading or updating itself. update-end
{
  error: <Error>,
  info: <Object>
}
Fired when the layer has finished updating its content. update-start Fired when the layer begins to update its content. visibility-change
{
  visible: <Boolean>
}
Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer.

Constructor Details

Creates a new instance of a feature layer object from the ArcGIS Server REST resource identified by the input URL. Once created you can optionally set a definition expression or time definition.

Parameters: <String> url Required URL to the ArcGIS Server REST resource that represents a feature service. An example is http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0. For more information on constructing a URL, see The Services Directory and the REST API. <Object> options Optional Optional parameters. See options list. options properties: <Boolean> allowUpdateWithoutMValues Optional Indicates whether attribute features containing m-values can be edited. Default value is false. <Boolean> autoGeneralize Optional Enable or disable the auto generalization of features from a non-editable layer in on-demand mode. When true, the layer uses the current map resolution as the maxAllowableOffset for all queries issued to the server. The default value is true. As of v2.7 <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 <Boolean> displayOnPan Optional When true, graphics are displayed during panning. When false, the graphics are turned off during pan movement. Setting to false may improve performance in Internet Explorer. The default is true. <Function> editSummaryCallback Optional Set a callback function that will be invoked by FeatureLayer.getEditSummary. As of v2.8 <Object> featureReduction Optional Enables feature reduction (for example clustering) on point layers. See setFeatureReduction() for more details. See the featureReduction object specification table below for options that may be set in this object.

Support for feature reduction is limited to the following scenarios:

<String> gdbVersion Optional Specify the geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater <String> id Optional Unique ID to assign to the layer. If not assigned, esri.Map creates a unique ID. <InfoTemplate> infoTemplate Optional The template that defines the content to display in the map info window when the user clicks on a feature. If not specified, the info window will not be displayed. <Number> maxAllowableOffset Optional The maximum allowable offset, only applicable for layers that are not editable. <Number> mode Optional The query mode for the feature layer. Each mode determines when and how many features are sent to the client. The default mode is to query on demand as the extent, time and layer definition changes. You can specify the following values: The default value is MODE_ONDEMAND.

See the constants table for additional details on each mode.

<Number> opacity Optional Initial 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. The default value is 1.0. Not supported in Internet Explorer. <String[]> orderByFields Optional One or more fields used to order features by - for queries as well as for rendering. <String[]> outFields Optional An array of strings which correspond to fields to include in the FeatureLayer. If not specified, the feature layer will return the OBJECTID field and if applicable the start time field, end time field and type id field. You can specify ["*"] to fetch the values for all fields in the layer, this is useful when editing features. <Number> refreshInterval Optional Refresh interval of the layer in minutes. Non-zero value sets up automatic layer refresh at the specified interval. <Object> resourceInfo Optional Specify the metadata of the layer. <Boolean> showAttribution Optional When true, the layer's attribution is displayed on the map. The default value is true. Added at v3.1
require([
  "esri/layers/FeatureLayer", ... 
], function(FeatureLayer, ... ) {
  var censusBlock = new FeatureLayer(layerUrl, {
    showAttribution :false
  });
  ...
});
<Boolean> showLabels Optional Indicates whether to show labels on the layer. 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. Indicate whether to display labels. If true, any FeatureLayer added to the map will automatically label based on labelingInfo. Default is false. Added at v3.11 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.


  var map = new Map("map", {showLabels : true });
  ...
  var fl1 = new FeatureLayer(url, {showLabels: true, outFields: ["*"]});
  var fl2 = new FeatureLayer(url2, {showLabels: false, outFields: ["*"]});
  map.addLayers([fls, fl2]);
Added at v3.11 <LayerSource> source Optional The dynamic layer or table source. The url should end with /dynamicLayer. <Number> tileHeight Optional Specify the size of the virtual tiles, used in on-demand mode. The virtual tile scheme is used in on-demand mode to make effective use of browser caching. The default value is 512. This option is only valid in on-demand mode and must be a square. For example, specifying a value like 512x256 is not supported. <Number> tileWidth Optional Specify the size of the virtual tiles, used in on-demand mode. The virtual tile scheme is used in on-demand mode to make effective use of browser caching. The default value is 512. This option is only valid in on-demand mode and must be a square. For example, specifying a value like 512x256 is not supported.
require([
  "esri/layers/FeatureLayer", ... 
], function(FeatureLayer, ... ) {
  var featureLayer = new FeatureLayer("https://www.example.com/arcgis/rest/services/Hydrography/Watershed173811/FeatureServer/1", {
    mode: FeatureLayer.MODE_ONDEMAND,
    tileWidth: 200,
    tileHeight: 200
  });
  ...
});
<String> trackIdField Optional The name of the trackIdField.
require([
  "esri/layers/FeatureLayer", ... 
], function(FeatureLayer, ... ) {
  var featureLayer = new FeatureLayer(featureLayerURL, {
    mode: FeatureLayer.MODE_SELECTION,
    trackIdField: "Animal_1"
  });
  ...
});
<Boolean> useMapTime Optional When true, the layer will update its content based on the map's time extent. The default values is true. <Boolean> visible Optional Initial visibility of the layer. Default is true. <Boolean> webglEnabled Optional Indicates if the layer will enable WebGL for rendering. Default value is true. Object Specifications:

<featureReduction>

<Number> clusterRadius Optional The radius in pixels of each area in which multiple points will be summarized and visualized as a single cluster. <InfoTemplate> infoTemplate Optional The InfoTemplate used to display summary information about aggregate graphics. <String> type Required The reduction (or aggregation) method for reducing the features displayed in the map. The only valid value is cluster. Sample:
require([
  "esri/InfoTemplate", "esri/layers/FeatureLayer", ... 
], function(InfoTemplate, FeatureLayer, ... ) {
  var infoTemplate = new InfoTemplate("${FIELD_NAME}", content);
  var featureLayer = new FeatureLayer("https://www.example.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer/0",{
    mode: FeatureLayer.MODE_ONDEMAND,
    infoTemplate: infoTemplate,
    outFields: ["*"]
  });
  ...
});

Creates a new instance of a feature layer using a FeatureCollection object. The feature layer, when initialized with a feature collection object has the following behavior:

Parameters: <Object> featureCollectionObject Required A feature collection object. See the object specifications tables below for details. <Object> options Optional Optional parameters. See options list. 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. Sample:
require([
  "esri/layers/FeatureLayer", ... 
], function(FeatureLayer, ... ) {
  var layerDefinition = {
    "geometryType": "esriGeometryPolygon",
    "fields": [{
      "name": "BUFF_DIST",
      "type": "esriFieldTypeInteger",
      "alias": "Buffer Distance"
    }]
  } 
  var featureCollection = {
    layerDefinition: layerDefinition,
    featureSet: null
  };
  var featureLayer = new FeatureLayer(featureCollection, {
    showLabels: true
  });
  ...
});

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,
  "supportsQueryWithCacheHint" : 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} */
});

Returns true if the geometry of the features in the layer can be edited, false otherwise. In ArcGIS Server version 10.1, this option can be configured when publishing the service. For earlier versions, this is always true. (Added at v2.8)

Known values: true | false

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

Default value: false

The URL, when available, where the layer's attribution data is stored. (Added at v3.1)

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.

Indicates the field names for the editor fields. If ownership based access control is not enabled for the feature service the value will be null. The object has the following properties:

  {
    <String> creatorField,
    <String> creationDateField,
    <String> editorField,
    <String> editDateField
  }
Requires ArcGIS Server feature service version 10.1 or greater. (Added at v2.6)

Applicable to ArcGIS Online hosted feature services. If present, this object specifies information about editing. See the object specifications table below for the structure of the editingInfo object. (Added at v3.28)

Object Specifications:

<editingInfo>

<Number> lastEditDate Required A read-only value that indicates the last time a layer was edited. This value gets updated every time the layer data is edited or when any of the layer properties change. The value is depicted as a Unix timestamp, e.g.
"editingInfo" : {
  "lastEditDate" : 1536363634886
}

The array of fields in the layer.

The full extent of the layer.

The geodatabase version. Only applicable if the layer's data source is registered as versioned in SDE. Only valid with ArcGIS Server services version 10.1 or greater. (Added at v2.7)

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

The globalIdField for the layer.

Array of features in the layer.

Indicates whether the layer displays all features intersecting the current view. Typically, this method should be called after the layer emits the

update-end

event.

(Added at v3.28)

Default value: true

True if attachments are enabled on the feature layer. Use the queryAttachmentInfos method to determine if the feature has attachments. If the layer is editable (isEditable) and supports attachments the following operations can be performed.

Known values: true | false

When true, the layer has attribution data. The default value is false. Use the

getAttributionData

method to retrieve this data as JSON.

(Added at v3.1)

Known values: true | false

Default value: false

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:

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)

The maximum number of results that will be returned from a query. Requires ArcGIS Server version 10.1 or greater. (Added at v2.6)

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.

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

Indicates the ownership access control configuration. If ownership based access control is not enabled for the feature service the value will be null. If ownership based access control is not enabled for the feature service the value will be null. This object has two properties

allowDeleteToOthers

and

allowUpdateToOthers

. When true features can be deleted or updated by users other than the creator.

{
  <Boolean> allowUpdateToOthers,
  <Boolean> allowDeleteToOthers
}
(Added at v2.6)

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)

Each element in the array is an object that describes the layer's relationship with another layer or table. Use the queryRelatedFeatures method to retrieve features or records related to a feature in this layer. The object has the following properties:

<Number> id Unique ID for the relationship <String> name Name of the relationship. <Number> relatedTableId Unique ID of the related table or layer Sample:
var relationships = wellFeatureLayer.relationships;
dojo.forEach(relationships,function(relationship){
  console.log("name: " + relationship.name);
  console.log("id: " + relationship.id);
  console.log("relationship id: "   + relationship.relatedTableId);
});

The renderer for the layer.

When true, the layer's attribution is displayed on the map. (Added at v3.1)

Known values: true | false

Default value: true

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

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

showLabels

is true.

If you do not wish to have your feature layer label, you can override this behavior by setting its showLabels property to false. NOTE: In order for the labels to display, all fields used by the labelingInfo should be set in outFields. In addition, only simple labeling is supported, for example {CITY_NAME}. For example, SQL keywords such as "CONCAT" are not supported. Consider using the LabelLayer class where you can specify the textExpression if needing more functionality.


Added at v3.11

Known values: true | false

Default value: true

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

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

Known values: true | false

When true, the layer supports orderByFields in a query operation. Requires ArcGIS Server service version 10.1 or greater (Added at v2.6)

Known values: true | false

When true, the layer supports uploading attachments with Uploads REST operation, which then can be used in the Add Attachment or Update Attachment REST operations. Requires ArcGIS Online hosted feature service. (Added at v3.11)

Known values: true | false

When true, the layer supports the Calculate REST operation when updating features. Requires ArcGIS Online hosted feature service. (Added at v3.11)

Known values: true | false

If true, the layer supports a user-defined field description. Please see the ArcGIS Online help topic,

Describe attribute fields

for additional information.

(Added at v3.28)

When true, the layer supports statistical functions in query operations. Requires ArcGIS Server service version 10.1 or greater (Added at v2.6)

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:

(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 field that represents the Type ID field. Only applicable for ArcGIS Server Feature Service layers.

An array of sub types defined in the Feature Service layer. Only applicable for ArcGIS Server Feature Service layers.

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

Parameters: <Number> objectId Required The ObjectId of the feature to which the attachment is added. <HTMLFormElement> formNode Required HTML form that contains a file upload field pointing to the file to be added as an attachment. If you are using HTML then your form should follow this basic pattern:
<form id="form1">
  <input type="file" id="fileinput" name="attachment" onchange="doSomething()" />
</form>
If you wish to create the form data in JavaScript, then you can create a form using the following pattern:
var formData = new FormData();
formData.append("attachment", file);
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the addAttachmentComplete event. <Function> errback Optional An error object is returned if an error occurs during task execution.

Apply edits to the feature layer. Applicable for layers created from a FeatureService or a FeatureCollection.

NOTE:

Date field values are always represented as

numeric

values. This means that when updating existing features, date fields must have numeric values and not date objects.

Parameters: <Graphic[]> adds Optional Array of features to add to the layer. New features are typically created using the Draw toolbar. <Graphic[]> updates Optional

Array of features whose geometry and/or attributes have changed. Features must have a valid OBJECTID. The geometry of features is typically modified using the Edit toolbar. Attributes are modified using the Attribute Inspector.

<Graphic[]> deletes Optional Array of features to delete. Must have valid ObjectId <Function> callback Optional This function will be called when the operation is complete. The arguments passed to this function are the same as the onEditsComplete event. <Function> errback Optional An error object is returned if an error occurs. Sample:
require([
  "esri/layers/FeatureLayer", ... 
], function(FeatureLayer, ... ) {
  var firePerimeterFL = new FeatureLayer( ... );
  var targetGraphic = firePerimeterFL.getSelectedFeatures()[0].setGeometry(reshapedGeometry);
  firePerimeterFL.applyEdits(null, [targetGraphic], null);
  ...
});

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 the current selection.

Delete one or more attachments for the feature specified by the input ObjectId. Only applicable if

isEditable

and

hasAttachments

are true.

Parameters: <Number> objectId Required The ObjectId of the feature from which the attachment is removed. <Number[]> attachmentIds Required The array of attachment ids to delete. <Function> callback Optional The function to call when the method has completed. <Function> errback Optional An error object is returned if an error occurs.

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();

Asynchrously returns custom data for the layer when available. (Added at v3.1)

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. Sample:

var capabilities = featureLayer.getEditCapabilities();

if(capabilities.canUpdate){

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

}

Returns an object describing the most recent edit operation performed on the given feature, if available. (Added at v2.8)

Parameters: <Graphic> feature Required The feature to get the edit info for. <Object> options Optional See the object specifications table below for the structure of the options object. Object Specifications:

<options>

<String> action Required By default, the method returns a summary of the most recent edit performed on the feature. Use this option to override this behavior. Sample:
{
  "action"        : "creation", // or "edit"
  "userId"        : "Mike",
  "minutes"       :  15,
  "hours"         :  5,
  "weekDay"       : "Tuesday",
  "formattedDate" : "1/1/2012",
  "formattedTime" : "9:30 AM",
  "displayPattern": "Minutes", // or "Seconds", "Minute", "Hour", "Hours", "WeekDay", "Full"
  "timeValue"     :  1330167842310
}

Returns a localized summary of the last edit operation performed on the given feature, if available. For example:

Edited by Bjorn seconds ago
Edited by Bjorn a minute ago
Edited by Bjorn 15 minutes ago
Edited by Bjorn an hour ago
Edited by Bjorn 5 hours ago
Edited by Bjorn on Tuesday at 1:30 PM
Edited by Bjorn on 4/27/2014 at 11:30 AM

The word "Edited" will be replaced by "Created" if the author has disabled editorField attribute but enabled creatorField attribute. The user component and date-time component may or may not be available depending on your layer's edit tracking settings (see

editFieldsInfo

property of this layer for more information). An empty string will be returned if:

Parameters: <Graphic> feature Required The feature to get the edit summary for. <Object> options Optional See the object specifications table below for the structure of the options object. Object Specifications:

<options>

<String> action Required By default, the method returns a summary of the most recent edit performed on the feature. Use this option to override this behavior. <Function> callback Required If you want to customize or override certain components of the summary, provide a callback function using this option. For example:
featureLayer.getEditSummary(feature, {
  callback: function(feature, info) {
    if (info && info.userId) {
      info.userId = "<a href='http://users.my.org/profile/" + info.userId     + "'>" + info.userId + "</a>";
    }
    return info;
  }
});

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.

(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.

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

Indicates if feature reduction (for example clustering) is active in the view. Feature reduction is active at all scales. At any given scale, if there are features that do not fall within a cluster, they are displayed as individual features. This method is only applicable to point layers when

feature reduction

is

enabled

.

(Added at v3.22) Sample:
featureLayer.isFeatureReductionActive();

Indicates if feature reduction (for example clustering) is enabled. Only applicable to point layers. See also

setFeatureReduction()

.

(Added at v3.22) Sample:
featureLayer.isFeatureReductionEnabled();

Returns true if the layer is visible at the given scale. (Added at v3.1)

Parameters: <Number> scale Required The scale at which to check if the layer is visible.

Query for information about attachments associated with the specified ObjectIds.

Parameters: <Number> objectId Required The ObjectId for the feature to query for attachment information. <Function> callback Optional The function to call when the method has completed. <Function> errback Optional An error object is returned if an error occurs.

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

Parameters: <Query> query Required

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

<Function> callback Optional The function to call when the method has completed. <Function> errback Optional An error object is returned if an error occurs. Sample:
require([
  "esri/tasks/query", "FeatureLayer", ... 
], function(Query, FeatureLayer, ... ) {
  var query = new Query();
  var featureLayer = new FeatureLayer( ... );
  query.where = "POP90_SQMI < 100";
  featureLayer.queryCount(query, function(count) {
    console.log(count + " features satisfied the input query");
  }, function(error) {
    console.log(error);
  });      
  ...
});

Get the extent of features that satisfy the input query. The count of features that satisfy the input query is returned as well. This is valid only for hosted feature services on arcgis.com and for ArcGIS Server 10.3.1 and later. (Added at v3.9)

Parameters: <Query> query Required The query definition. <Function> callback Optional The function called when the method has completed. <Function> errback Optional The function called when error occurred.

Query features from the feature layer. Layer definition and time definition are honored. Whenever possible the feature layer will perform the query on the client.

Parameters: <Query> query Required

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

<Function> callback Optional The function to call when the method has completed. <Function> errback Optional An error object is returned if an error occurs. Sample:
require([
  "esri/layers/FeatureLayer", "esri/tasks/query", ... 
], function(FeatureLayer, Query, ... ) {
  featureLayer = new FeatureLayer( ... );
  var query = new Query();
  query.objectIds = [features[0].attributes.OBJECTID];
  query.outFields = [ "*" ];
  // Query for the features with the given object ID
  featureLayer.queryFeatures(query, function(featureSet) {
  });
  ...
});

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

Parameters: <Query> query Required

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

<Function> callback Optional The function to call when the method has completed. <Function> errback Optional An error object is returned if an error occurs. Sample:
require([
  "esri/layers/FeatureLayer", "esri/tasks/query", ... 
], function(FeatureLayer, Query, ... ) {
  var featureLayer = new FeatureLayer( ... );
  // create a query to fetch object IDs for all records
  var query = new Query();
  query.where = "1=1";
  
  featureLayer.queryIds(query, function(objectIds) {
    //do something with the objectIds here
  });
  ...
});

Query features or records, from another layer or table, related to features in this layer.

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

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

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

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.

<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:

(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
  });

Set the layer's data source to the specified geodatabase version. If the versionName is null then the data source will be the published map's default version. Only applicable if the layer's data source is registered as versioned in SDE. Only valid with ArcGIS Server services version 10.1 or greater. (Added at v2.7)

Parameters: <String> versionName Required The name of the geodatabase version to use as the layer's data source.

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-vector",
    center:[-80, 30],
    zoom: 4,
    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 addAttachments() is complete. Should be used in favor of onAddAttachmentComplete. (Added at v3.5)

Event Object Properties: <FeatureEditResult> result The result of the addAttachment operation indicating if the attachment was successfully added.

Fired before edits are applied to the feature layer. Should be used in favor of onBeforeApplyEdits. (Added at v3.5)

Event Object Properties: <Graphic[]> adds Array of features to add to the layer in the feature service. <Graphic[]> deletes Array of features to delete. <Graphic[]> updates Array of features whose geometry and/or attributes have changed.

Fired when the capabilities of the layer are modified using the setEditable method. Should be used in favor of onCapabilitiesChange. (Added at v3.5)

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 deleteAttachments is complete. Should be used in favor of onDeleteAttachmentsComplete. (Added at v3.5)

Event Object Properties: <Object[]> results The result objects, one for each attachment indicating if it was successfully removed.

Fires after applyEdits() is complete. Should be used in favor of onEditsComplete. (Added at v3.5)

Event Object Properties: <FeatureEditResult[]> adds An array of result objects, one for each feature, indicating if it was successfully added. If the feature was added the result object will contain the unique object ID assigned to the feature. <FeatureEditResult[]> deletes An array of result objects, one for each feature, indicating if it was successfully deleted. If the feature was deleted the result object will contain the unique object ID previously assigned to the feature. <FeatureEditResult[]> updates An array of result objects, one for each feature, indicating if it was successfully updated. If the feature was updated the result object will contain the unique object ID assigned to the feature.

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:

(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:

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 queryAttachmentInfos method is called. Should be used in favor of onQueryAttachmentInfosComplete. (Added at v3.5)

Event Object Properties: <Object[]> info Information about the attachments associated with the feature. Each element in this array is an object with the following properties: objectId,url,id,name,contentType,size.

Fires when the query for the count is complete. This event is only available for layers published using ArcGIS Server 10 SP1 or later. Should be used in favor of onQueryCountComplete. (Added at v3.5)

Event Object Properties: <Number> count The number of features that satisfy the input query.

Fires when queryExtent method has completed. (Added at v3.9)

Event Object Properties: <Number> count The count of features. <Extent> extent The extent of features.

Fires when queryFeatures() is complete. Should be used in favor of onQueryFeaturesComplete. (Added at v3.5)

Event Object Properties: <FeatureSet> featureSet The FeatureSet returned from the query.

Fires when queryIds() is complete. Should be used in favor of onQueryIdsComplete. (Added at v3.5)

Event Object Properties: <Number[]> objectIds Array of ObjectIds returned from the query.

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

Fires when queryRelatedFeatures() is complete. Should be used in favor of onQueryRelatedFeaturesComplete. (Added at v3.5)

Event Object Properties: <Object> relatedFeatures An object that contains feature sets. Each feature set contains features, from the target layer/table, related to the source feature. In the example below 15 and 9 are the object IDs of the features in the source layer/table.
{
  "15": <FeatureSet1>,
  "9":  <FeatureSet2>
}

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

Fires right before the actual refresh kicks in for the layer, and only fires when the refresh is triggered by the

refreshInterval

.

(Added at v3.27)

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

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

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

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

Fires when selectFeatures() completes. Should be used in favor of onSelectionComplete. (Added at v3.5)

Event Object Properties: <Graphic[]> features Features returned from the query. This does not equal the current selection, call getSelectedFeatures() to retrieve the current selection set. <Number> method Selection method used in the selectFeatures method.

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

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

Fired when the layer has finished updating its content. This event is always preceded by update-start. Should be used in favor of onUpdateEnd. (Added at v3.5)

Event Object Properties: <Error> error Optional argument available when an error occurs during the update. <Object> info Optional object that may have a boolean queryLimitExceeded property. queryLimitExceeded will be true if the feature layer could not draw all features due to a maxRecordCount limitation on the query operation. As of v2.8

Fired when the layer begins to update its content. The following table describes when the event is fired in various modes.

Snapshot OnDemand 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.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4