Class AnnotationLayer

  • All Implemented Interfaces:
    RemoteResource, LayerContent, Loadable

    public final class AnnotationLayer
    extends Layer
    implements RemoteResource
    A layer that can visualize annotation text data.

    Annotation can be used to symbolize text on your maps as described here in "Annotation". It is defined using a text string, geographical location, and display properties including font, size, and color. This information is stored together in an annotation feature class within a geodatabase. There are two kinds of annotation:

    • Standard annotation is not formally associated with features in the geodatabase. An example of standard annotation is the text on a map for a mountain range. No specific feature represents the mountain range, but it is an area you want to mark. Standard annotation is read-only.
    • Feature-linked annotation is associated with a specific feature in another feature class in the geodatabase. The text in feature-linked annotation reflects the value of a field or fields from the feature to which it is linked. For example, the water transmission mains in a water network can be annotated with their names, which are stored in a field in the transmission mains feature class. If you edit the attributes and/or geographical position of the feature associated with the feature-linked annotation, any changes will be applied to the annotation feature table, and visible changes to the annotation will be reflected in the MapView. If the feature-linked annotation is stored in an Enterprise server, its feature and annotation tables must contain global object ids.

    You can construct an annotation layer using any of the following:

    Annotation layers can be taken offline from a feature service hosted on ArcGIS Enterprise 10.7.1 or later, using the GeodatabaseSyncTask. Annotation layers are also supported in mobile map packages created in ArcGIS Pro 2.3 or later.

    Annotation respects the reference scale defined by the map, so annotation will always be presented to the user at the correct size and position, as defined by the annotation author.

    Each annotation layer is partitioned into annotation sublayers. Each annotation sublayer corresponds to the label class of the original labels that were used to publish the annotation. In ArcGIS Pro, the annotation sublayers are known as annotation classes.

    Annotation sublayers offer greater control over the annotation:

    • An author can set different visual properties on the sublayer compared to the parent annotation layer. For example, font, size, color, or different minimum and maximum scale ranges.
    • You can access the annotation sublayer metadata information, such as the legend information, and set the visibility of each annotation sublayer.
    Since:
    100.5.0
    See Also:
    Layer
    • Constructor Detail

      • AnnotationLayer

        public AnnotationLayer​(PortalItem portalItem,
                               long layerId)
        Creates an annotation layer for a layer within a feature service portal item.
        Parameters:
        portalItem - a feature service PortalItem
        layerId - the layer ID for which to create the layer
        Throws:
        java.lang.IllegalArgumentException - if portalItem is null
        Since:
        100.5.0
      • AnnotationLayer

        public AnnotationLayer​(java.lang.String url)
        Creates an annotation layer from a feature service URL. If the specified URL is not a valid feature service endpoint, then it will fail to load.

        To use a credential, call setCredential(Credential) after this constructor and before loading or using this layer.

        Parameters:
        url - the URL of the feature service
        Throws:
        java.lang.IllegalArgumentException - if the URL is null or empty
        Since:
        100.5.0
      • AnnotationLayer

        public AnnotationLayer​(ArcGISFeatureTable featureTable)
        Creates an annotation layer from a feature table containing annotation features.

        If the feature table does not contain annotation data then the AnnotationLayer will fail to load. ArcGISFeatureTable.getLayerInfo() and ArcGISFeatureLayerInfo.getServiceType() can be checked, to verify the feature type, before attempting to create a Layer.

        Parameters:
        featureTable - the feature table, containing annotation features, used as the source of the annotation layer
        Throws:
        java.lang.IllegalArgumentException - if featureTable is null
        Since:
        100.6.0
    • Method Detail

      • setCredential

        public void setCredential​(Credential credential)
        Description copied from interface: RemoteResource
        Sets a Credential to be used by the network-enabled resource in the event of an authentication challenge. The default credential is null.

        Only applicable if the resource is secured.

        Specified by:
        setCredential in interface RemoteResource
        Parameters:
        credential - the Credential to be used for authentication
      • getCredential

        public Credential getCredential()
        Description copied from interface: RemoteResource
        Gets the Credential that is set on the network-enabled resource.

        Only applicable if the resource is secured.

        Specified by:
        getCredential in interface RemoteResource
        Returns:
        the Credential, or null if there is none
      • getUri

        public java.lang.String getUri()
        Gets the URL of the feature service associated with this layer.
        Specified by:
        getUri in interface RemoteResource
        Returns:
        the URL of the feature service
        Since:
        100.5.0
      • getBarrierWeight

        public LabelBarrierWeight getBarrierWeight()
        Gets the weight of annotation features when considered as barriers to labeling.

        The default is LabelBarrierWeight.HIGH.

        Returns:
        the weight of annotation features when considered as barriers to labeling
        Since:
        100.14.0
      • setBarrierWeight

        public void setBarrierWeight​(LabelBarrierWeight barrierWeight)
        Sets the weight of annotation features when considered as barriers to labeling.

        The default is LabelBarrierWeight.HIGH.

        Parameters:
        barrierWeight - the weight of annotation features when considered as barriers to labeling
        Throws:
        java.lang.IllegalArgumentException - if barrierWeight is null
        Since:
        100.14.0
      • getDefinitionExpression

        public java.lang.String getDefinitionExpression()
        Gets an expression which is a SQL statement where clause to specify the subset of features to be displayed.

        The definition expression string uses the SQL-92 where clause syntax the SQL-92 where clause syntax. The default value is an empty string, which will allow all annotation features in the data source to be used by the AnnotationLayer.

        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.

        Returns:
        an expression which is a SQL statement where clause to specify the subset of features to be displayed
        Since:
        100.12.0
      • setDefinitionExpression

        public void setDefinitionExpression​(java.lang.String definitionExpression)
        Sets an expression which is a SQL statement where clause to specify the subset of features to be displayed.

        The definition expression string uses the SQL-92 where clause syntax the SQL-92 where clause syntax. The default value is an empty string, which will allow all annotation features in the data source to be used by the AnnotationLayer.

        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:
        definitionExpression - an expression which is a SQL statement where clause to specify the subset of features to be displayed
        Throws:
        java.lang.IllegalArgumentException - if definitionExpression is null
        Since:
        100.12.0
      • getFeatureTable

        public ArcGISFeatureTable getFeatureTable()
        Gets the feature table associated with this layer.
        Returns:
        the feature table, or null if none
        Since:
        100.6.0
      • getLayerId

        public long getLayerId()
        Gets the layer ID that defines the layer within the feature service portal item.
        Returns:
        the layer ID
        Since:
        100.5.0
      • getReferenceScale

        public double getReferenceScale()
        Gets the reference scale for the layer.

        The reference scale of the layer is the scale at which a client should view the map for the feature symbols and text to appear at their authored size. If the client changes the viewing scale, then feature symbols and text will grow or shrink to keep a consistent size on the map (not the screen). The reference scale will be zero if the layer is not loaded or if there is no reference scale and the symbols and text should appear at default size regardless of the viewing scale.

        Returns:
        the reference scale
        Since:
        100.5.0
      • copy

        public AnnotationLayer copy()
        Creates a deep copy of this AnnotationLayer instance. This means that copies of all fields of this layer are made including its load state.
        Returns:
        a deep copy of this AnnotationLayer instance
        Since:
        100.5.0
      • clearSelection

        public void clearSelection()
        Updates any selected features in the layer back to the un-selected state.
        Since:
        100.12.0
      • resetFeaturesVisible

        public void resetFeaturesVisible()
        Resets the visibility of the layer's features back to the original visibility when loaded from the data source.
        Since:
        100.12.0
      • selectFeature

        public void selectFeature​(Feature feature)
        Selects the given feature and adds it to the current list of selected features.
        Parameters:
        feature - the feature
        Throws:
        java.lang.IllegalArgumentException - if feature is null
        Since:
        100.12.0
      • selectFeatures

        public void selectFeatures​(java.lang.Iterable<Feature> features)
        Selects the features in the list and adds them to the current list of selected features.
        Parameters:
        features - a Iterable of Feature. Contents of the Iterable are copied.
        Throws:
        java.lang.IllegalArgumentException - if features is null
        Since:
        100.12.0
      • selectFeaturesAsync

        public ListenableFuture<FeatureQueryResult> selectFeaturesAsync​(QueryParameters parameters,
                                                                        FeatureLayer.SelectionMode mode)
        Selects the features that match the criteria in the QueryParameters object and adds them to the current list of selected features.
        Parameters:
        parameters - the definition of the query to submit to the feature table
        mode - defines how the list of currently selected features will be updated with the features returned from the query.
        Returns:
        a ListenableFuture that returns a FeatureQueryResult
        Throws:
        java.lang.IllegalArgumentException - if parameters is null
        java.lang.IllegalArgumentException - if mode is null
        Since:
        100.12.0
      • setFeatureVisible

        public void setFeatureVisible​(Feature feature,
                                      boolean visible)
        Sets the visibility of the given feature.
        Parameters:
        feature - the feature
        visible - true to show, false to hide
        Throws:
        java.lang.IllegalArgumentException - if feature is null
        Since:
        100.12.0
      • setFeaturesVisible

        public void setFeaturesVisible​(java.lang.Iterable<Feature> features,
                                       boolean visible)
        Sets the visibility of the given features.
        Parameters:
        features - a Iterable of Feature. Contents of the Iterable are copied.
        visible - true to show, false to hide
        Throws:
        java.lang.IllegalArgumentException - if features is null
        Since:
        100.12.0
      • unselectFeature

        public void unselectFeature​(Feature feature)
        Unselects the given feature and removes it from the current list of selected features.
        Parameters:
        feature - the feature
        Throws:
        java.lang.IllegalArgumentException - if feature is null
        Since:
        100.12.0
      • unselectFeatures

        public void unselectFeatures​(java.lang.Iterable<Feature> features)
        Unselects the features in the given list and removes them from the current list of selected features.
        Parameters:
        features - a Iterable of Feature. Contents of the Iterable are copied.
        Throws:
        java.lang.IllegalArgumentException - if features is null
        Since:
        100.12.0