Class FeatureLayer

  • All Implemented Interfaces:
    TimeAware, LayerContent, Loadable, PopupSource

    public final 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

        public FeatureLayer​(FeatureTable featureTable)
        Constructs the FeatureLayer with the given FeatureTable.
        Parameters:
        featureTable - feature table for this feature layer
        Throws:
        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:
        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:
        IllegalArgumentException - if milliseconds is less than zero
        Since:
        100.1.0
      • getDefinitionExpression

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

        public 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.
        Parameters:
        expression - the definition expression, it can be null
        Since:
        100.0.0
      • 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
      • isPopupEnabled

        public boolean isPopupEnabled()
        Description copied from interface: PopupSource
        Gets a flag indicating whether the PopupDefinition returned from PopupSource.getPopupDefinition() is enabled or disabled.
        Specified by:
        isPopupEnabled in interface PopupSource
        Returns:
        a flag indicating whether the PopupDefinition is enabled or disabled
      • setPopupEnabled

        public void setPopupEnabled​(boolean enabled)
        Description copied from interface: PopupSource
        Sets a flag indicating whether the PopupDefinition returned from PopupSource.getPopupDefinition() is enabled or disabled.
        Specified by:
        setPopupEnabled in interface PopupSource
        Parameters:
        enabled - true to enable the PopupDefinition, otherwise false
      • 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 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:
        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:
        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:
        IllegalArgumentException - if feature is null
        Since:
        100.0.0
      • selectFeatures

        public void selectFeatures​(Iterable<Feature> features)
        Adds features to the current selection.
        Parameters:
        features - the features to be added to selection
        Throws:
        IllegalArgumentException - if features 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:
        IllegalArgumentException - if feature is null
        Since:
        100.0.0
      • setFeaturesVisible

        public void setFeaturesVisible​(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:
        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:
        IllegalArgumentException - if feature is null
        Since:
        100.0.0
      • unselectFeatures

        public void unselectFeatures​(Iterable<Feature> features)
        Removes multiple features from selection.
        Parameters:
        features - features to be unselected
        Throws:
        IllegalArgumentException - if features is null
        Since:
        100.0.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