java.lang.Object
com.esri.arcgisruntime.layers.Layer
All Implemented Interfaces:
LayerContent, Loadable
Direct Known Subclasses:
AnnotationLayer, ArcGISSceneLayer, ArcGISVectorTiledLayer, DimensionLayer, DynamicEntityLayer, EncLayer, FeatureCollectionLayer, FeatureLayer, GroupLayer, ImageAdjustmentLayer, IntegratedMeshLayer, KmlLayer, MobileBasemapLayer, Ogc3DTilesLayer, PointCloudLayer, UnknownLayer, UnsupportedLayer

public abstract class Layer extends Object implements Loadable, LayerContent
A base class for classes that represent layers.

A layer, also known as an operational layer, provides access to geographic data that is displayed in a map or scene. Each layer references a file or service data source that contains either vector data (points, lines, polygons and attributes) or raster data (images). The ArcGISMap or ArcGISScene can display these layers inside a MapView or SceneView, respectively. To enhance the displayed information, you can 'stack' the layers into a collection of GeoModel.getOperationalLayers() or GeoModel.getOperationalLayers(). The first layer in the collection is drawn first (on the bottom) and each subsequent layer is drawn on top of it.

Layer is the base class for these different types of layers:

Subclasses of Layer
Layer type 2D/3D Time-aware Online/offline Sources
Annotation layer (AnnotationLayer) 2D No Both ArcGIS feature service, portal item, mobile map package (.mmpk)
ArcGIS map image layer (ArcGISMapImageLayer) Both Yes Online ArcGIS map service
ArcGIS scene layer (ArcGISSceneLayer) 3D No Both Scene service or scene package
ArcGIS tiled layer (ArcGISTiledLayer) Both No Both ArcGIS tile service, tile package (.tpk/.tpkx)
ArcGIS vector tiled layer (ArcGISVectorTiledLayer) Both No Both ArcGIS vector tile service, vector tile package (.vtpk)
Bing maps layer (BingMapsLayer) Both No Online Bing maps
Dimension layer (DimensionLayer) 2D Yes Offline Mobile map package (.mmpk)
Dynamic entity layer (DynamicEntityLayer) Both No Online ArcGIS stream service
ENC layer (EncLayer) 2D No Offline ENC exchange set, ENC cell
Feature collection layer (FeatureCollectionLayer) Both No Both Portal item, web map, feature set / query result
Feature layer (FeatureLayer) Both Yes Both ArcGIS feature service, WFS, shapefile, GeoPackage, geodatabase, OGC API Features
Group layer (GroupLayer) Both No Both Other layers and group layers
KML layer (KmlLayer) Both Yes Both KML file (.kml, .kmz)
Integrated mesh layer (IntegratedMeshLayer) 3D No Both Scene layer package (.slpk)
Mobile basemap layer (MobileBasemapLayer) 2D No Offline Mobile map package (.mmpk)
OGC 3D Tiles layer (Ogc3DTilesLayer) 3D No Both Portal item, tileset, tile package(.3tz)
OpenStreetMap layer (OpenStreetMapLayer) Both No Online OpenStreetMap.org
Point cloud layer (PointCloudLayer) 3D No Both Portal item, scene layer package (.slpk)
Raster layer (RasterLayer) Both Yes Both GeoPackage, raster file, ArcGIS Image service
Subtype feature layer (SubtypeFeatureLayer) 2D No Both ArcGIS feature service, geodatabase
Web tiled layer (WebTiledLayer) Both No Online Web tile service
WMS layer (WmsLayer) Both Yes Online WMS service
WMTS layer (WmtsLayer) Both No Online WMTS service
Since:
100.0.0
  • Property Details

  • Method Details

    • getAttribution

      public String getAttribution()
      Gets the attribution for this layer, such as data providers or copyright text.
      Returns:
      the attribution for this layer
      Since:
      100.0.0
    • getDescription

      public String getDescription()
      Gets the description of this layer.
      Returns:
      the description of this layer
      Since:
      100.0.0
    • setDescription

      public void setDescription(String description)
      Sets the description of this layer.
      Parameters:
      description - the description to set on this layer
      Since:
      100.0.0
    • getFullExtent

      public Envelope getFullExtent()
      Gets the full extent of this layer, which is the extent where all layer data is contained.

      You can use this to zoom to all of the data contained in this layer. For feature layers, the extent is retrieved from its FeatureTable.getExtent().

      Returns:
      the full extent of this layer
      Since:
      100.0.0
      See Also:
    • getId

      public String getId()
      Gets the unique identifying string for the layer, as specified in a map or scene.

      The id is used by other parts of this API to refer to a specific Layer, such as in a set of FeatureFenceParameters or a FacilityLayerDefinition. If not supplied, all layers will be assigned a unique id when created.

      Returns:
      the unique identifying string for the layer, as specified in a map or scene
      Since:
      100.0.0
      See Also:
    • setId

      public void setId(String id)
      Sets the unique identifying string for the layer, as specified in a map or scene.

      The id is used by other parts of this API to refer to a specific Layer, such as in a set of FeatureFenceParameters or a FacilityLayerDefinition. If not supplied, all layers will be assigned a unique id when created.

      It is not recommended to change this property when the layer is obtained from a map or scene. If changed, ensure that the string is unique, for example based on a generated GUID.

      Parameters:
      id - the unique identifying string for the layer, for example specified in a map or scene
      Throws:
      IllegalArgumentException - if id is null
      Since:
      100.0.0
    • getMaxScale

      public double getMaxScale()
      Gets the maximum zoom scale for this layer. This determines the maximum scale level this layer can zoom to.

      The maximum scale at which this layer is visible. If the map or scene is zoomed in beyond this scale, the layer will not be visible. A value of 0 means there is no maximum scale threshold and the layer will be visible at the smallest scale available for the map or scene. All of the connected map and scene views will be updated.

      Returns:
      the maximum scale level this layer can zoom to
      Since:
      100.0.0
    • setMaxScale

      public void setMaxScale(double maxScale)
      Sets the maximum zoom scale for this layer. This controls the maximum scale level this layer can zoom to.

      The maximum scale at which this layer is visible. If the map or scene is zoomed in beyond this scale, the layer will not be visible. A value of 0 means there is no maximum scale threshold and the layer will be visible at the smallest scale available for the map or scene. All of the connected map and scene views will be updated.

      Parameters:
      maxScale - the maximum scale level this layer can zoom to
      Since:
      100.0.0
    • getMinScale

      public double getMinScale()
      Gets the minimum zoom scale for this layer. This determines the minimum scale level this layer can zoom to.

      The minimum scale at which this layer is visible. If the map or scene is zoomed out beyond this scale, the layer will not be visible. A value of 0 means there is no minimum scale threshold and the layer will be visible at the largest scale available for the map or scene. If the value is nil, there is no minimum scale. All of the connected map and scene views will be updated.

      Returns:
      the minimum scale level this layer can zoom to
      Since:
      100.0.0
    • setMinScale

      public void setMinScale(double minScale)
      Sets the minimum zoom scale for this layer. This controls the minimum scale level this layer can zoom to.

      The minimum scale at which this layer is visible. If the map or scene is zoomed out beyond this scale, the layer will not be visible. A value of 0 means there is no minimum scale threshold and the layer will be visible at the largest scale available for the map or scene. If the value is nil, there is no minimum scale. All of the connected map and scene views will be updated.

      Parameters:
      minScale - the minimum scale level this layer can zoom to
      Since:
      100.0.0
    • getName

      public String getName()
      Gets the name of this layer.
      Specified by:
      getName in interface LayerContent
      Returns:
      the name of this layer
      Since:
      100.0.0
    • setName

      public void setName(String name)
      Sets the name of this layer.
      Parameters:
      name - the name of this layer
      Since:
      100.0.0
    • getOpacity

      public float getOpacity()
      Gets the opacity of this layer.

      The opacity of this layer as a value between 0 (fully transparent) and 1 (fully opaque). The default opacity value is 1.

      Returns:
      The opacity of this layer, which is a value in the range of 0.0 - 1.0, with the default being 1.0 which is fully opaque.
      Since:
      100.0.0
    • setOpacity

      public void setOpacity(float opacity)
      Sets the opacity of this layer.

      The opacity of this layer as a value between 0 (fully transparent) and 1 (fully opaque). The default opacity value is 1.

      Parameters:
      opacity - the opacity of this layer, which needs to be a value in the range of 0.0 - 1.0, 1.0 being fully opaque
      Since:
      100.0.0
    • getItem

      public Item getItem()
      Gets the Item associated with this layer.
      Returns:
      the associated Item or null if this layer is not associated with an Item
      Since:
      100.0.0
    • getSpatialReference

      public SpatialReference getSpatialReference()
      Gets the spatial reference of this layer.
      Returns:
      the spatial reference of this layer
      Since:
      100.0.0
    • isIdentifyEnabled

      public boolean isIdentifyEnabled()
      True if the layer supports identify, false otherwise.

      The value of this property may not be correct until the layer is in a fully loaded state.

      Returns:
      true if the layer supports identify, false otherwise
      Since:
      100.2.0
    • addVisibilityChangedListener

      public void addVisibilityChangedListener(VisibilityChangedListener listener)
      Adds a visibility changed listener to the layer.
      Parameters:
      listener - the visibility changed listener to add
      Throws:
      IllegalArgumentException - if the listener is null
      Since:
      100.9.0
    • removeVisibilityChangedListener

      public void removeVisibilityChangedListener(VisibilityChangedListener listener)
      Removes the visibility changed listener from the layer.
      Parameters:
      listener - the visibility changed listener to be removed
      Since:
      100.9.0
    • canChangeVisibility

      public boolean canChangeVisibility()
      Description copied from interface: LayerContent
      Checks whether we can change the visibility of this layer.
      Specified by:
      canChangeVisibility in interface LayerContent
      Returns:
      true if we can change this layer's visibility; false otherwise
    • isVisible

      public boolean isVisible()
      Description copied from interface: LayerContent
      Checks if this layer is visible or not.
      Specified by:
      isVisible in interface LayerContent
      Returns:
      true if the layer is visible; false otherwise
      See Also:
    • setVisible

      public void setVisible(boolean visible)
      Description copied from interface: LayerContent
      Sets the layer's visibility if LayerContent.canChangeVisibility() returns true.
      Specified by:
      setVisible in interface LayerContent
      Parameters:
      visible - true to make the layer visible; false to hide it
      See Also:
    • isVisibleAtScale

      public boolean isVisibleAtScale(double scale)
      Description copied from interface: LayerContent
      Checks if this layer has effective visibility at the given scale. This effective visibility takes care of the effective visibility of the parents at the specified scale.
      Specified by:
      isVisibleAtScale in interface LayerContent
      Parameters:
      scale - the scale the visibility has to be calculated for
      Returns:
      true if the layer will be visible at the given scale; false otherwise
    • canShowInLegend

      public boolean canShowInLegend()
      Description copied from interface: LayerContent
      Checks if this layer will be listed in the legend.
      Specified by:
      canShowInLegend in interface LayerContent
      Returns:
      true if this layer will be visible in the legend; false otherwise
    • setCanShowInLegend

      public void setCanShowInLegend(boolean canShowInLegend)
      Description copied from interface: LayerContent
      Sets whether or not this layer should be visible in the legend.
      Specified by:
      setCanShowInLegend in interface LayerContent
      Parameters:
      canShowInLegend - true to show in the legend; false to omit it from the legend
    • getSubLayerContents

      public ListenableList<LayerContent> getSubLayerContents()
      Description copied from interface: LayerContent
      Returns a list of sub layers, if any. If there are no sub-layers, an empty list will be returned. This list cannot be used to add or remove sub-layers.
      Specified by:
      getSubLayerContents in interface LayerContent
      Returns:
      a read only list of sub-layers, if any
    • fetchLegendInfosAsync

      public ListenableFuture<List<LegendInfo>> fetchLegendInfosAsync()
      Description copied from interface: LayerContent
      Asynchronously fetches a list of legend information for this layer, if any.
      Specified by:
      fetchLegendInfosAsync in interface LayerContent
      Returns:
      a listenable future that can be used to get the legend information. Null is returned if an error occurs.
    • getLoadStatus

      public LoadStatus getLoadStatus()
      Gets the value of the loadStatus property.
      Specified by:
      getLoadStatus in interface Loadable
      Property description:
      Returns:
      the value of the loadStatus property
      See Also:
    • getLoadError

      public ArcGISRuntimeException getLoadError()
      Gets the value of the loadError property.
      Specified by:
      getLoadError in interface Loadable
      Property description:
      Returns:
      the value of the loadError property
      See Also:
    • loadAsync

      public void loadAsync()
      Description copied from interface: Loadable
      Loads the metadata of the loadable resource asynchronously.

      The load status changes from LoadStatus.NOT_LOADED to LoadStatus.LOADING. A listener can be added via Loadable.addDoneLoadingListener(java.lang.Runnable) that is invoked upon completion of the asynchronous load operation.

      If the load operation completes successfully, the load status will be LoadStatus.LOADED, which means the resource has loaded its metadata.

      If the load operation failed, the load status will be LoadStatus.FAILED_TO_LOAD and the error can be retrieved by calling Loadable.getLoadError().

      This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (LoadStatus.LOADING state) when loadAsync is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED or LoadStatus.FAILED_TO_LOAD state) when loadAsync is called, the done loading listener is immediately invoked when added to the loadable resource.

      If a loadable resource has failed to load, calling loadAsync on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource, Loadable.retryLoadAsync() needs to be used.

      A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling Loadable.cancelLoad().

      Specified by:
      loadAsync in interface Loadable
    • retryLoadAsync

      public void retryLoadAsync()
      Description copied from interface: Loadable
      Loads or retries loading metadata for the object asynchronously.

      Will retry loading the metadata if the object's load status is LoadStatus.FAILED_TO_LOAD. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.

      For more details on the load process see Loadable.loadAsync().

      Specified by:
      retryLoadAsync in interface Loadable
    • cancelLoad

      public void cancelLoad()
      Description copied from interface: Loadable
      Cancels loading metadata for the object.

      Cancels loading the metadata if the object is loading, and always invokes the done loading listener.

      A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling this method and the resource will transition from LoadStatus.LOADING to LoadStatus.FAILED_TO_LOAD state. If the load operation was successfully cancelled, a CancellationException will be returned from Loadable.getLoadError().

      Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.

      This method does nothing if the resource is not in LoadStatus.LOADING state.

      Specified by:
      cancelLoad in interface Loadable
    • addDoneLoadingListener

      public void addDoneLoadingListener(Runnable listener)
      Description copied from interface: Loadable
      Adds a listener to the loadable resource that is invoked when loading has completed.

      The listener may be added at any point, whether the loadable resource has already completed loading or not.

      • For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
      • For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.

      Alternatively, to be notified when there is any change in the load status, add a listener to the Loadable.loadStatusProperty() instead.

      Specified by:
      addDoneLoadingListener in interface Loadable
      Parameters:
      listener - a Runnable that is invoked upon completion of the load operation
    • removeDoneLoadingListener

      public boolean removeDoneLoadingListener(Runnable listener)
      Description copied from interface: Loadable
      Removes a done loading listener from the loadable resource.
      Specified by:
      removeDoneLoadingListener in interface Loadable
      Parameters:
      listener - the listener to be removed
      Returns:
      true if the listener was removed, otherwise false
    • addLoadStatusChangedListener

      public void addLoadStatusChangedListener(LoadStatusChangedListener listener)
      Description copied from interface: Loadable
      Adds a LoadStatusChangedListener to the loadable resource that is invoked whenever the load status changes.

      Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

      The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the Loadable.addDoneLoadingListener(Runnable) method.

      Specified by:
      addLoadStatusChangedListener in interface Loadable
      Parameters:
      listener - the LoadStatusChangedListener to be added
    • removeLoadStatusChangedListener

      public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
      Description copied from interface: Loadable
      Removes a LoadStatusChangedListener from the loadable resource.
      Specified by:
      removeLoadStatusChangedListener in interface Loadable
      Parameters:
      listener - the LoadStatusChangedListener to be removed
      Returns:
      true if the listener was removed, otherwise false
    • loadStatusProperty

      public ReadOnlyObjectProperty<LoadStatus> loadStatusProperty()
      Description copied from interface: Loadable
      The load status.
      Specified by:
      loadStatusProperty in interface Loadable
      Returns:
      the loadStatus property
      See Also:
    • loadErrorProperty

      public ReadOnlyObjectProperty<ArcGISRuntimeException> loadErrorProperty()
      Description copied from interface: Loadable
      The load error.
      Specified by:
      loadErrorProperty in interface Loadable
      Returns:
      the loadError property
      See Also: