Class Layer
- java.lang.Object
-
- com.esri.arcgisruntime.layers.Layer
-
- All Implemented Interfaces:
LayerContent
,Loadable
- Direct Known Subclasses:
AnnotationLayer
,ArcGISSceneLayer
,ArcGISVectorTiledLayer
,DimensionLayer
,EncLayer
,FeatureCollectionLayer
,FeatureLayer
,GroupLayer
,ImageAdjustmentLayer
,IntegratedMeshLayer
,KmlLayer
,MobileBasemapLayer
,PointCloudLayer
,UnknownLayer
,UnsupportedLayer
public abstract class Layer extends java.lang.Object implements Loadable, LayerContent
The abstract base class of all layer types.Layer
is the base class for all layer types. A layer is a representation of geographic data portrayed using symbols and text labels. Multiple layers can be 'stacked' to enhance the information displayed. Layers are displayed in aArcGISMap
inside aMapView
control and in anArcGISScene
inSceneView
. Layers are drawn bottom-to-top, so the first layer in a map's layer collection is drawn first (on the bottom) and each subsequent layer is drawn on top of it.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
)2D 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) 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) 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDoneLoadingListener(java.lang.Runnable listener)
Adds a listener to the loadable resource that is invoked when loading has completed.void
addLoadStatusChangedListener(LoadStatusChangedListener listener)
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.void
addVisibilityChangedListener(VisibilityChangedListener listener)
Adds a visibility changed listener to the layer.void
cancelLoad()
Cancels loading metadata for the object.boolean
canChangeVisibility()
Checks whether we can change the visibility of this layer.boolean
canShowInLegend()
Checks if this layer will be listed in the legend.ListenableFuture<java.util.List<LegendInfo>>
fetchLegendInfosAsync()
Asynchronously fetches a list of legend information for this layer, if any.java.lang.String
getAttribution()
Gets the attribution for this layer, such as data providers or copyright text.java.lang.String
getDescription()
Gets the description of this layer.Envelope
getFullExtent()
Gets the full extent of this layer, which is the extent where all layer data is contained.java.lang.String
getId()
Returns a string that represents the layer's unique ID in the map.Item
getItem()
Gets the Item associated with this layer.ArcGISRuntimeException
getLoadError()
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.LoadStatus
getLoadStatus()
Returns theLoadStatus
of the loadable resource.double
getMaxScale()
Gets the maximum zoom scale for this layer.double
getMinScale()
Gets the minimum zoom scale for this layer.java.lang.String
getName()
Gets the name of this layer.float
getOpacity()
Gets the opacity of this layer.SpatialReference
getSpatialReference()
Gets the spatial reference of this layer.ListenableList<LayerContent>
getSubLayerContents()
Returns a list of sub layers, if any.boolean
isIdentifyEnabled()
Gets whether the layer supports identify.boolean
isVisible()
Checks if this layer is visible or not.boolean
isVisibleAtScale(double scale)
Checks if this layer has effective visibility at the given scale.void
loadAsync()
Loads the metadata of the loadable resource asynchronously.boolean
removeDoneLoadingListener(java.lang.Runnable listener)
Removes a done loading listener from the loadable resource.boolean
removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Removes aLoadStatusChangedListener
from the loadable resource.void
removeVisibilityChangedListener(VisibilityChangedListener listener)
Removes the visibility changed listener from the layer.void
retryLoadAsync()
Loads or retries loading metadata for the object asynchronously.void
setCanShowInLegend(boolean canShowInLegend)
Sets whether or not this layer should be visible in the legend.void
setDescription(java.lang.String description)
Sets the description of this layer.void
setId(java.lang.String id)
Sets a string that represents the layer's unique ID in the map.void
setMaxScale(double maxScale)
Sets the maximum zoom scale for this layer.void
setMinScale(double minScale)
Sets the minimum zoom scale for this layer.void
setName(java.lang.String name)
Sets the name of this layer.void
setOpacity(float opacity)
Sets the opacity of this layer.void
setVisible(boolean visible)
Sets the layer's visibility ifLayerContent.canChangeVisibility()
returns true.
-
-
-
Method Detail
-
getAttribution
public java.lang.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 java.lang.String getDescription()
Gets the description of this layer.- Returns:
- the description of this layer
- Since:
- 100.0.0
-
setDescription
public void setDescription(java.lang.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 features contained in this feature layer. This is calculated from the feature table.- Returns:
- the full extent of this layer
- Since:
- 100.0.0
- See Also:
FeatureTable.getExtent()
-
getId
public java.lang.String getId()
Returns a string that represents the layer's unique ID in the map. For layers from existing maps, this is set by the authoring application. For layers added to a new map, it is the authoring application's responsibility to set this to a unique value.- Returns:
- a string containing the ID that uniquely identifies this layer at runtime
- Since:
- 100.0.0
- See Also:
setId(java.lang.String)
-
setId
public void setId(java.lang.String id)
Sets a string that represents the layer's unique ID in the map. For layers from existing maps, this is set by the authoring application and should not be overwritten. For layers added to a new map, it is the authoring application's responsibility to set this to a unique value.- Parameters:
id
- the ID to set- Throws:
java.lang.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.- 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.- 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.- 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.- Parameters:
minScale
- the minimum scale level this layer can zoom to- Since:
- 100.0.0
-
getName
public java.lang.String getName()
Gets the name of this layer.- Specified by:
getName
in interfaceLayerContent
- Returns:
- the name of this layer
- Since:
- 100.0.0
-
setName
public void setName(java.lang.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.- 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.- 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()
Gets whether the layer supports identify.If the layer is not loaded this may return false if identify support is determined by metadata that is not yet available.
- 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:
java.lang.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 interfaceLayerContent
- 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 interfaceLayerContent
- Returns:
- true if the layer is visible; false otherwise
- See Also:
LayerContent.setVisible(boolean)
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:LayerContent
Sets the layer's visibility ifLayerContent.canChangeVisibility()
returns true.- Specified by:
setVisible
in interfaceLayerContent
- Parameters:
visible
- true to make the layer visible; false to hide it- See Also:
LayerContent.isVisible()
-
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 interfaceLayerContent
- 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 interfaceLayerContent
- 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 interfaceLayerContent
- 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 interfaceLayerContent
- Returns:
- a read only list of sub-layers, if any
-
fetchLegendInfosAsync
public ListenableFuture<java.util.List<LegendInfo>> fetchLegendInfosAsync()
Description copied from interface:LayerContent
Asynchronously fetches a list of legend information for this layer, if any.- Specified by:
fetchLegendInfosAsync
in interfaceLayerContent
- Returns:
- a listenable future that can be used to get the legend information. Null is returned if an error occurs.
-
getLoadStatus
public LoadStatus getLoadStatus()
Description copied from interface:Loadable
Returns theLoadStatus
of the loadable resource.- Specified by:
getLoadStatus
in interfaceLoadable
- Returns:
- the LoadStatus of the loadable resource
-
getLoadError
public ArcGISRuntimeException getLoadError()
Description copied from interface:Loadable
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.If the resource subsequently transitions to
LoadStatus.LOADED
(for example, if a call toretryLoadAsync
completes successfully) the error is cleared out.- Specified by:
getLoadError
in interfaceLoadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
LoadStatus.FAILED_TO_LOAD
state.
-
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
toLoadStatus.LOADING
. A listener can be added viaLoadable.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 callingLoadable.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) whenloadAsync
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
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
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 callingLoadable.cancelLoad()
.
-
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 interfaceLoadable
-
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 fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.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 interfaceLoadable
-
addDoneLoadingListener
public void addDoneLoadingListener(java.lang.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, use the
Loadable.addLoadStatusChangedListener(LoadStatusChangedListener)
method instead.- Specified by:
addDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
public boolean removeDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Removes a done loading listener from the loadable resource.- Specified by:
removeDoneLoadingListener
in interfaceLoadable
- 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 aLoadStatusChangedListener
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 interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
-