public class

FeatureLayer

extends Layer
implements PopupLayer
java.lang.Object
   ↳ com.esri.android.map.Layer
     ↳ com.esri.android.map.FeatureLayer

Class Overview

FeatureLayer is a type of Layer composed of features; features in a FeatureLayer comprise a geometry and a consistent set of attributes. Features in a FeatureLayer can be displayed on a map, queried, edited, and selected (visually highlighted). Each feature has a unique ID.

One FeatureLayer corresponds to one FeatureTable, which is passed in to the FeatureLayer constructor. In order to be correctly displayed, the getSpatialReference() value must match the spatial reference of the map to which the FeatureLayer is added. If the feature layer's FeatureTable is a GeodatabaseFeatureServiceTable, set the spatial reference by calling the setSpatialReference(SpatialReference) method. When the FeatureTable is a GeodatabaseFeatureTable obtained from a Geodatabase, set the spatial reference when generating the geodatabase using a GeodatabaseSyncTask by calling the setOutSpatialRef(SpatialReference) method.

Summary

Nested Classes
enum FeatureLayer.SelectionMode The modes used for selecting features. 
[Expand]
Inherited Fields
From class com.esri.android.map.Layer
Public Constructors
FeatureLayer(FeatureTable featureTable)
Constructs the FeatureLayer with the given FeatureTable.
Public Methods
void clearSelection()
Clears the current feature selection.
FeatureTablePopupInfo createPopupInfo()
Creates the popup info.
String getDefinitionExpression()
Returns the definition expression of the layer.
Feature getFeature(long oid)
Gets the Feature specified by its ID.
long[] getFeatureIDs(float x, float y, int tolerance)
Identifies the features for the specified device screen coordinates and search tolerance.
long[] getFeatureIDs(float x, float y, int tolerance, int numberOfResults)
Identifies the features for the specified device screen coordinates and search tolerance.
FeatureTable getFeatureTable()
Returns the feature table that represents the data source of this layer.
Geometry.Type getGeometryType()
Returns the geometry type.
Renderer getRenderer()
Gets the Renderer of the layer.
List<Feature> getSelectedFeatures()
Returns the selected features in a list.
int getSelectionColor()
Returns the color applied to a selected feature.
long[] getSelectionIDs()
Returns an array of IDs of selected features.
boolean isEnabledLabels()
Returns true if labeling is enabled for the layer, otherwise false.
boolean isFeatureSelected(long id)
Determines if the feature with the given ID is selected.
boolean isPopupAllowGeometryUpdate(Feature feature)
Returns true if the popup allow the geometry to be updated, potentially based on some information carried by the Feature provided.
boolean isPopupDeletable(Feature feature)
Returns true if the popup created is deletable, potentially based on some information carried by the Feature provided.
boolean isPopupEditable(Feature feature)
Returns true if the popup created is editable, potentially based on some information carried by the Feature provided.
void recycle()
Releases resources referenced by the Layer so that they can be recycled.
void selectFeature(long oid)
Selects the feature for the given feature ID
void selectFeatures(long[] oids, boolean inclusive)
Sets the selected features with given feature IDs, the selected features will be highlighted.
Future<FeatureResult> selectFeatures(QueryParameters queryParams, FeatureLayer.SelectionMode selectionMode, CallbackListener<FeatureResult> callback)
Selects features in the layer based on a query.
final void setDefinitionExpression(String expression)
Sets a definition expression which is a SQL statement where clause to filter out the features to be displayed.
void setEnableLabels(boolean enable)
Enables or disables the labeling for the layer.
void setFeatureVisible(long oid, boolean visible)
Sets the visibility of the feature with the given object ID.
void setRenderer(Renderer renderer)
Sets the Renderer of the layer.
void setSelectionColor(int selectionColor)
Sets the color that is applied to a selected feature.
void setSelectionColorWidth(int highlightWidth)
Sets selection color width.
void unselectFeature(long oid)
Un-selects the feature specified by its object ID.
void unselectFeatures(FeatureResult iter)
Un-selects the feature for the given feature iterator.
void unselectFeatures(long[] ids)
Un-selects the feature for the given array of feature IDs.
Protected Methods
long create()
void fetchFeatures(long[] existingIds, double[] extent, double scale)
Request callback from the runtime core to fetch features for the specified extent/scale.
void initLayer()
Initializes the layer.
[Expand]
Inherited Methods
From class com.esri.android.map.Layer
From class java.lang.Object
From interface com.esri.android.map.popup.PopupLayer

Public Constructors

public FeatureLayer (FeatureTable featureTable)

Constructs the FeatureLayer with the given FeatureTable.

Parameters
featureTable FeatureTable: a FeatureTable object.

Public Methods

public void clearSelection ()

Clears the current feature selection.

public FeatureTablePopupInfo createPopupInfo ()

Creates the popup info.

Returns
FeatureTablePopupInfo the ArcGIS popup info

public String getDefinitionExpression ()

Returns the definition expression of the layer.

Returns
String String

public Feature getFeature (long oid)

Gets the Feature specified by its ID.

Parameters
oid long: the object ID of the feature
Returns
Feature the Feature or null if the feature doesn't exist in the layer

public long[] getFeatureIDs (float x, float y, int tolerance)

Identifies the features for the specified device screen coordinates and search tolerance.

Parameters
x float: screen coordinate x
y float: screen coordinate y
tolerance int: search tolerance in DP (device independent pixels).
Returns
long[] an array of feature IDs or empty/null for nothing.

public long[] getFeatureIDs (float x, float y, int tolerance, int numberOfResults)

Identifies the features for the specified device screen coordinates and search tolerance.

Parameters
x float: screen coordinate x
y float: screen coordinate y
tolerance int: search tolerance in DP (device independent pixels).
numberOfResults int: the maximum number for results to be returned.
Returns
long[] an array of feature IDs or empty/null for nothing.

public FeatureTable getFeatureTable ()

Returns the feature table that represents the data source of this layer.

Returns
FeatureTable a FeatureTable object.

public Geometry.Type getGeometryType ()

Returns the geometry type.

Returns
Geometry.Type Geometry type enum.

public Renderer getRenderer ()

Gets the Renderer of the layer.

Returns
Renderer a Renderer object.

public List<Feature> getSelectedFeatures ()

Returns the selected features in a list.

Returns
List<Feature> a list of Features.

public int getSelectionColor ()

Returns the color applied to a selected feature.

Returns
int a color integer in ARGB format.

public long[] getSelectionIDs ()

Returns an array of IDs of selected features.

Returns
long[] an array of feature IDs.

public boolean isEnabledLabels ()

Returns true if labeling is enabled for the layer, otherwise false.

Returns
boolean a boolean indicating whether labeling is enabled

public boolean isFeatureSelected (long id)

Determines if the feature with the given ID is selected.

Parameters
id long: a feature ID
Returns
boolean true if the feature is selected, otherwise false.

public boolean isPopupAllowGeometryUpdate (Feature feature)

Returns true if the popup allow the geometry to be updated, potentially based on some information carried by the Feature provided.

Returns
boolean

public boolean isPopupDeletable (Feature feature)

Returns true if the popup created is deletable, potentially based on some information carried by the Feature provided.

Returns
boolean

public boolean isPopupEditable (Feature feature)

Returns true if the popup created is editable, potentially based on some information carried by the Feature provided.

Returns
boolean

public void recycle ()

Releases resources referenced by the Layer so that they can be recycled.

public void selectFeature (long oid)

Selects the feature for the given feature ID

Parameters
oid long: the object ID of the feature to be selected

public void selectFeatures (long[] oids, boolean inclusive)

Sets the selected features with given feature IDs, the selected features will be highlighted.

Parameters
oids long: the object IDs of the features to be selected
inclusive boolean: true if the supplied features will be added to the selection; false if the supplied graphics are the only selected features.

public Future<FeatureResult> selectFeatures (QueryParameters queryParams, FeatureLayer.SelectionMode selectionMode, CallbackListener<FeatureResult> callback)

Selects features in the layer based on a query.

Parameters
queryParams QueryParameters: a QueryParameters object
selectionMode FeatureLayer.SelectionMode: the FeatureLayer.SelectionMode used to select features
callback CallbackListener: CallbackListener object
Returns
Future<FeatureResult> Future object

public final void setDefinitionExpression (String expression)

Sets a definition expression which is a SQL statement where clause to filter out the features to be displayed. The definition expression is used to query the feature table related to the feature layer and only features meeting the query criteria will be displayed on the layer. It will not alter the feature table itself.

The field name is not case sensitive, e.g. a valid where clause string like:

"NAME = 'City Hall'"
"apn ='011861126'"
"owner_name like 's%'"

or more complex example like:

"OBJECTID <= (SELECT OBJECTID FROM LANDMARK_1 WHERE NAME = 'City Hall')"

There are no error checks involved when setting the expression. A null or empty string will redisplay all features for the layer; an invalid clause will not cause any changes to the features currently displayed but may result in a geodatabase exception. No features are displayed if a valid clause is supplied but there are no features meeting its criteria.

Notes:This definition expression is different from the one on the ERROR(/GeodatabaseFeatureServiceTable#setDefinitionExpression(string)), this one will affect the features to be displayed on the layer, the latter be applied to the server and affects how many the features to be fetched.

Parameters
expression String: String in the form of a where clause.

public void setEnableLabels (boolean enable)

Enables or disables the labeling for the layer.

Parameters
enable boolean: true if labeling should be enabled, otherwise false

public void setFeatureVisible (long oid, boolean visible)

Sets the visibility of the feature with the given object ID.

Parameters
oid long: the ID of the feature.
visible boolean: if true the feature will be made visible, otherwise it will be hidden.

public void setRenderer (Renderer renderer)

Sets the Renderer of the layer.

Parameters
renderer Renderer: a Renderer object.

public void setSelectionColor (int selectionColor)

Sets the color that is applied to a selected feature.

Parameters
selectionColor int: a color integer in ARGB format.

public void setSelectionColorWidth (int highlightWidth)

Sets selection color width.

Parameters
highlightWidth int: integer in DP (device independent pixels).

public void unselectFeature (long oid)

Un-selects the feature specified by its object ID.

Parameters
oid long: the object ID of the feature to un-select.

public void unselectFeatures (FeatureResult iter)

Un-selects the feature for the given feature iterator.

Parameters
iter FeatureResult: a feature iterator

public void unselectFeatures (long[] ids)

Un-selects the feature for the given array of feature IDs.

Parameters
ids long: an array of feature IDs.

Protected Methods

protected long create ()

Returns
long

protected void fetchFeatures (long[] existingIds, double[] extent, double scale)

Request callback from the runtime core to fetch features for the specified extent/scale.

Parameters
existingIds long: existing feature IDs in the geodatabase.
extent double: current map extent.
scale double: current map scale.

protected void initLayer ()

Initializes the layer. The implementation should submit the OnStatusChangedListener.STATUS event accordingly.