Class FeatureLayer

  • All Implemented Interfaces:
    TimeAware, LayerContent, Loadable, PopupSource
    Direct Known Subclasses:
    SubtypeFeatureLayer

    public class FeatureLayer
    extends Layer
    implements PopupSource, TimeAware
    Represents a Layer composed of features; features in a FeatureLayer comprise a geometry and a consistent set of fields. Features in a FeatureLayer can be displayed on a map, queried, edited, and selected (visually highlighted).

    Each FeatureLayer corresponds to one FeatureTable, which is passed in to the FeatureLayer constructor.

    Since:
    100.0.0
    • Constructor Detail

      • FeatureLayer

        protected FeatureLayer​(com.esri.arcgisruntime.internal.jni.CoreFeatureLayer coreFeatureLayer,
                               PortalItem portalItem,
                               boolean addToCache)
        Constructor that creates a wrapper for coreFeatureLayer's CoreFeatureTable, rather than using a FeatureTable that's been passed in by the app.
        Parameters:
        coreFeatureLayer - the core layer to wrap
        portalItem - an existing PortalItem to use, or null if none exists yet and we need to ask the layer if it has a CorePortalItem in which case we create a wrapper for it
        addToCache - if true, adds this FeatureLayer instance to the wrapper cache
        Since:
        100.0.0
      • FeatureLayer

        public FeatureLayer​(FeatureTable featureTable)
        Constructs the FeatureLayer with the given FeatureTable.
        Parameters:
        featureTable - feature table for this feature layer
        Throws:
        java.lang.IllegalArgumentException - if featureTable is null
        Since:
        100.0.0
      • FeatureLayer

        public FeatureLayer​(PortalItem portalItem,
                            long layerId)
        Creates a new FeatureLayer based on a layer within a feature service PortalItem.

        If the portal item argument is not in LoadStatus#LOADED state it will be loaded automatically when this FeatureLayer instance is loaded.

        Parameters:
        portalItem - a feature service PortalItem
        layerId - the ID of a layer within the feature service
        Throws:
        java.lang.IllegalArgumentException - if portalItem is null
        Since:
        100.0.0
    • Method Detail

      • copy

        public FeatureLayer copy()
        Creates a deep copy of this FeatureLayer instance.
        Returns:
        a deep copy of this FeatureLayer instance, which means that copies of all fields of this layer are made including its loading state
        Since:
        100.1.0
      • getRefreshInterval

        public long getRefreshInterval()
        Gets the refresh interval in milliseconds. The refresh interval is the time between automatic layer requests. A value of zero means the layer is never refreshed. The default value is zero.
        Returns:
        the refresh interval in milliseconds
        Since:
        100.1.0
      • setRefreshInterval

        public void setRefreshInterval​(long refreshIntervalMilliseconds)
        Sets the refresh interval in milliseconds. The refresh interval is the time between automatic layer requests. A value of zero means the layer is never refreshed. The default value is zero.
        Parameters:
        refreshIntervalMilliseconds - the refresh interval in milliseconds
        Throws:
        java.lang.IllegalArgumentException - if milliseconds is less than zero
        Since:
        100.1.0
      • getDefinitionExpression

        public java.lang.String getDefinitionExpression()
        Gets the definition expression applied to layer by the developer.
        Returns:
        the definition expression
        Since:
        100.0.0
        See Also:
        setDefinitionExpression(String)
      • setDefinitionExpression

        public void setDefinitionExpression​(java.lang.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.

        The definition expression string uses the SQL-92 where clause syntax. Be sure to escape special characters in the expression string as required for your platform. The DATE keyword expects the date format yyyy-mm-dd and the TIMESTAMP keyword expects the time stamp format yyyy-mm-dd hh:mm:ss. See the ArcGIS Blog article entitled "Querying Feature Services Date-Time Queries". for more information.

        Parameters:
        expression - the definition expression, it can be null
        Since:
        100.0.0
        See Also:
        getDefinitionExpression()
      • setPopupDefinition

        public void setPopupDefinition​(PopupDefinition popupDefinition)
        Sets the PopupDefinition for the FeatureLayer, overriding the previous one (for example, the one defined in the FeatureLayer definition).
        Specified by:
        setPopupDefinition in interface PopupSource
        Parameters:
        popupDefinition - the PopupDefinition to set
        Since:
        100.0.0
        See Also:
        PopupSource.getPopupDefinition()
      • isScaleSymbols

        public boolean isScaleSymbols()
        Gets whether the layer's symbols and labels honor the map reference scale.

        If the map has a positive reference scale, and the layer honors it, then symbols and labels will be drawn at their specified size when the viewing scale is the same as the reference scale, and will grow or shrink as the view zooms in or out, to keep the symbol a fixed size on the map. If the map has no reference scale, the reference scale is zero, or the FeatureLayer's scaleSymbols property is false, then the symbols and labels will be drawn at their fixed screen size.

        Returns:
        true if the layer's symbols and labels honor the map reference scale, false if not
        Since:
        100.5.0
      • setScaleSymbols

        public void setScaleSymbols​(boolean scaleSymbols)
        Sets whether the layer's symbols and labels honor the map reference scale.

        If the map has a positive reference scale, and the layer honors it, then symbols and labels will be drawn at their specified size when the viewing scale is the same as the reference scale, and will grow or shrink as the view zooms in or out, to keep the symbol a fixed size on the map. If the map has no reference scale, the reference scale is zero, or the FeatureLayer's scaleSymbols property is false, then the symbols and labels will be drawn at their fixed screen size.

        Parameters:
        scaleSymbols - true if the layer's symbols and labels should honor the map reference scale, false if not
        Since:
        100.5.0
      • setLabelsEnabled

        public void setLabelsEnabled​(boolean enabled)
        Enables or disables the labeling for the layer.
        Parameters:
        enabled - true to enable, false to disable labels
        Since:
        100.0.0
      • isLabelsEnabled

        public boolean isLabelsEnabled()
        Gets whether labels are enabled.
        Returns:
        true if labels are enabled, false if not
        Since:
        100.0.0
      • getLabelDefinitions

        public java.util.List<LabelDefinition> getLabelDefinitions()
        Gets a modifiable list of label definitions of the feature layer.
        Returns:
        a modifiable list of label definitions
        Since:
        100.1.0
      • getFeatureTable

        public FeatureTable getFeatureTable()
        Get the associated FeatureTable for FeatureLayer.
        Returns:
        the feature table
        Since:
        100.0.0
      • getRenderer

        public Renderer getRenderer()
        Gets the layer's current renderer.
        Returns:
        the renderer
        Since:
        100.0.0
      • setRenderer

        public void setRenderer​(Renderer renderer)
        Sets the layer's renderer
        Parameters:
        renderer - the renderer to be used for this layer
        Throws:
        java.lang.IllegalArgumentException - if renderer is null
        Since:
        100.0.0
      • setSelectionColor

        @Deprecated
        public void setSelectionColor​(int selectionColor)
        Deprecated.
        As of 100.4.0, use SelectionProperties.setColor(int) from your GeoView.
        Sets the color that is applied to a selected feature.
        Parameters:
        selectionColor - an integer representing the selection color as 0xAARRGGBB
        Since:
        100.0.0
      • getSelectionColor

        @Deprecated
        public int getSelectionColor()
        Deprecated.
        As of 100.4.0, use SelectionProperties.getColor() from your GeoView.
        Returns the color applied to a selected feature.
        Returns:
        an integer representing the selection color as 0xAARRGGBB
        Since:
        100.0.0
      • getSelectionWidth

        @Deprecated
        public double getSelectionWidth()
        Deprecated.
        As of 100.4.0, no replacement.
        Gets the width of the selection highlight.
        Returns:
        the width of the selection highlight
        Since:
        100.0.0
      • setSelectionWidth

        @Deprecated
        public void setSelectionWidth​(double width)
        Deprecated.
        As of 100.4.0, no replacement.
        Sets the width of the selection highlight.
        Parameters:
        width - the width of the selection highlight
        Throws:
        java.lang.IllegalArgumentException - if width is less than 0
        Since:
        100.0.0
      • getSelectedFeaturesAsync

        public ListenableFuture<FeatureQueryResult> getSelectedFeaturesAsync()
        Gets all the features selected.
        Returns:
        a future that represents the selected features
        Since:
        100.0.0
      • clearSelection

        public void clearSelection()
        Clears the selection.
        Since:
        100.0.0
      • resetFeaturesVisible

        public void resetFeaturesVisible()
        Resets all features back to the visible state.
        Since:
        100.0.0
      • resetRenderer

        public void resetRenderer()
        Resets the renderer to the layer's default renderer.
        Since:
        100.0.0
      • selectFeature

        public void selectFeature​(Feature feature)
        Adds the feature to the current selection.
        Parameters:
        feature - the feature to be added to selection
        Throws:
        java.lang.IllegalArgumentException - if feature is null
        Since:
        100.0.0
      • selectFeatures

        public void selectFeatures​(java.lang.Iterable<Feature> features)
        Adds features to the current selection.
        Parameters:
        features - the features to be added to selection
        Throws:
        java.lang.IllegalArgumentException - if features is null
        Since:
        100.0.0
      • selectFeaturesAsync

        public ListenableFuture<FeatureQueryResult> selectFeaturesAsync​(QueryParameters query,
                                                                        FeatureLayer.SelectionMode selectionMode)
        Selects features, asynchronously, based on query and selection mode.
        Parameters:
        query - the query to be applied to select features
        selectionMode - the selection mode to be used
        Returns:
        the result as a Future
        Throws:
        java.lang.IllegalArgumentException - if query or selectionMode is null
        Since:
        100.0.0
      • setFeatureVisible

        public void setFeatureVisible​(Feature feature,
                                      boolean visible)
        Makes a feature visible or invisible.
        Parameters:
        feature - feature to change visibility of
        visible - true to show, false to hide
        Throws:
        java.lang.IllegalArgumentException - if feature is null
        Since:
        100.0.0
      • setFeaturesVisible

        public void setFeaturesVisible​(java.lang.Iterable<Feature> features,
                                       boolean visible)
        Makes multiple features visible or invisible.
        Parameters:
        features - features to change visibility of
        visible - true to show, false to hide
        Throws:
        java.lang.IllegalArgumentException - if features is null
        Since:
        100.0.0
      • unselectFeature

        public void unselectFeature​(Feature feature)
        Removes a feature from selection.
        Parameters:
        feature - feature to be unselected
        Throws:
        java.lang.IllegalArgumentException - if feature is null
        Since:
        100.0.0
      • unselectFeatures

        public void unselectFeatures​(java.lang.Iterable<Feature> features)
        Removes multiple features from selection.
        Parameters:
        features - features to be unselected
        Throws:
        java.lang.IllegalArgumentException - if features is null
        Since:
        100.0.0
      • setRenderingMode

        public void setRenderingMode​(FeatureLayer.RenderingMode renderingMode)
        Sets the rendering mode.
        Parameters:
        renderingMode - the rendering mode
        Throws:
        java.lang.IllegalArgumentException - if renderingMode is null
        Since:
        100.2.0
      • getSceneProperties

        public LayerSceneProperties getSceneProperties()
        Gets a layer scene properties object that can be used to make changes to how features are displayed in a SceneView.

        These settings will have no effect if the layer is displayed in a MapView.

        Returns:
        a layer scene properties object
        Since:
        100.2.0
      • getFullTimeExtent

        public TimeExtent getFullTimeExtent()
        Description copied from interface: TimeAware
        Returns the full time extent of the object. Will be null if the object is not time aware.
        Specified by:
        getFullTimeExtent in interface TimeAware
        Returns:
        the time extent, or null if the object is not time aware
      • getTimeInterval

        public TimeValue getTimeInterval()
        Description copied from interface: TimeAware
        Returns the suggested time slider step size for this time aware object. Can be null if no time interval is suggested for this time aware object.
        Specified by:
        getTimeInterval in interface TimeAware
        Returns:
        the time interval, or null if there is no time interval
      • getTimeOffset

        public TimeValue getTimeOffset()
        Description copied from interface: TimeAware
        Returns the time offset applied to this object. The offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared.
        Specified by:
        getTimeOffset in interface TimeAware
        Returns:
        the time offset, or null if no offset has been set
      • isTimeFilteringEnabled

        public boolean isTimeFilteringEnabled()
        Description copied from interface: TimeAware
        Returns whether or not the object must use the time extent defined on the owning GeoView to filter its data.
        Specified by:
        isTimeFilteringEnabled in interface TimeAware
        Returns:
        true if time filtering is enabled; otherwise false
      • setIsTimeFilteringEnabled

        public void setIsTimeFilteringEnabled​(boolean enabled)
        Description copied from interface: TimeAware
        Enables or disables whether the object must use the time extent defined on the owning GeoView to filter its data.
        Specified by:
        setIsTimeFilteringEnabled in interface TimeAware
        Parameters:
        enabled - true to enable time filtering; otherwise false
      • isTimeFilteringSupported

        public boolean isTimeFilteringSupported()
        Description copied from interface: TimeAware
        Returns whether or not the object supports filtering its contents by time values with the extent set on the owning GeoView.
        Specified by:
        isTimeFilteringSupported in interface TimeAware
        Returns:
        true if time filtering is supported; otherwise false
      • setTimeOffset

        public void setTimeOffset​(TimeValue timeOffset)
        Description copied from interface: TimeAware
        Sets a time offset for this object. The time offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared. Can be null if there is no time offset.
        Specified by:
        setTimeOffset in interface TimeAware
        Parameters:
        timeOffset - the time offset, or null if there is no time offset
      • getUnknownJson

        public java.util.Map<java.lang.String,​java.lang.Object> getUnknownJson()
        Gets unknown data from the source JSON. Unknown JSON is a dictionary of values that was in the source JSON but was not parsed by the Runtime.
        Returns:
        an unmodifiable map with string keys and object values
        Since:
        100.7.0
      • getUnsupportedJson

        public java.util.Map<java.lang.String,​java.lang.Object> getUnsupportedJson()
        Gets unsupported data from the source JSON. Unsupported JSON is a dictionary of values that are supported by webmaps, but not exposed through the native Runtime API
        Returns:
        an unmodifiable map with string keys and object values
        Since:
        100.7.0