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.Layeris 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 aArcGISMapinside aMapViewcontrol and in anArcGISSceneinSceneView. 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 SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDoneLoadingListener(java.lang.Runnable listener)Adds a listener to the loadable resource that is invoked when loading has completed.voidaddLoadStatusChangedListener(LoadStatusChangedListener listener)Adds aLoadStatusChangedListenerto the loadable resource that is invoked whenever the load status changes.voidaddVisibilityChangedListener(VisibilityChangedListener listener)Adds a visibility changed listener to the layer.voidcancelLoad()Cancels loading metadata for the object.booleancanChangeVisibility()Checks whether we can change the visibility of this layer.booleancanShowInLegend()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.StringgetAttribution()Gets the attribution for this layer, such as data providers or copyright text.java.lang.StringgetDescription()Gets the description of this layer.EnvelopegetFullExtent()Gets the full extent of this layer, which is the extent where all layer data is contained.java.lang.StringgetId()Returns a string that represents the layer's unique ID in the map.ItemgetItem()Gets the Item associated with this layer.ArcGISRuntimeExceptiongetLoadError()Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOADstate, either due to calling theLoadable.loadAsync()orLoadable.retryLoadAsync()method.LoadStatusgetLoadStatus()Returns theLoadStatusof the loadable resource.doublegetMaxScale()Gets the maximum zoom scale for this layer.doublegetMinScale()Gets the minimum zoom scale for this layer.java.lang.StringgetName()Gets the name of this layer.floatgetOpacity()Gets the opacity of this layer.SpatialReferencegetSpatialReference()Gets the spatial reference of this layer.ListenableList<LayerContent>getSubLayerContents()Returns a list of sub layers, if any.booleanisIdentifyEnabled()Gets whether the layer supports identify.booleanisVisible()Checks if this layer is visible or not.booleanisVisibleAtScale(double scale)Checks if this layer has effective visibility at the given scale.voidloadAsync()Loads the metadata of the loadable resource asynchronously.booleanremoveDoneLoadingListener(java.lang.Runnable listener)Removes a done loading listener from the loadable resource.booleanremoveLoadStatusChangedListener(LoadStatusChangedListener listener)Removes aLoadStatusChangedListenerfrom the loadable resource.voidremoveVisibilityChangedListener(VisibilityChangedListener listener)Removes the visibility changed listener from the layer.voidretryLoadAsync()Loads or retries loading metadata for the object asynchronously.voidsetCanShowInLegend(boolean canShowInLegend)Sets whether or not this layer should be visible in the legend.voidsetDescription(java.lang.String description)Sets the description of this layer.voidsetId(java.lang.String id)Sets a string that represents the layer's unique ID in the map.voidsetMaxScale(double maxScale)Sets the maximum zoom scale for this layer.voidsetMinScale(double minScale)Sets the minimum zoom scale for this layer.voidsetName(java.lang.String name)Sets the name of this layer.voidsetOpacity(float opacity)Sets the opacity of this layer.voidsetVisible(boolean visible)Sets the layer's visibility ifLayerContent.canChangeVisibility()returns true.
 
- 
- 
- 
Method Detail- 
getAttributionpublic 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
 
 - 
getDescriptionpublic java.lang.String getDescription() Gets the description of this layer.- Returns:
- the description of this layer
- Since:
- 100.0.0
 
 - 
setDescriptionpublic 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
 
 - 
getFullExtentpublic 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()
 
 - 
getIdpublic 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)
 
 - 
setIdpublic 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
 
 - 
getMaxScalepublic 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
 
 - 
setMaxScalepublic 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
 
 - 
getMinScalepublic 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
 
 - 
setMinScalepublic 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
 
 - 
getNamepublic java.lang.String getName() Gets the name of this layer.- Specified by:
- getNamein interface- LayerContent
- Returns:
- the name of this layer
- Since:
- 100.0.0
 
 - 
setNamepublic void setName(java.lang.String name) Sets the name of this layer.- Parameters:
- name- the name of this layer
- Since:
- 100.0.0
 
 - 
getOpacitypublic 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
 
 - 
setOpacitypublic 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
 
 - 
getItempublic 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
 
 - 
getSpatialReferencepublic SpatialReference getSpatialReference() Gets the spatial reference of this layer.- Returns:
- the spatial reference of this layer
- Since:
- 100.0.0
 
 - 
isIdentifyEnabledpublic 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
 
 - 
addVisibilityChangedListenerpublic 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
 
 - 
removeVisibilityChangedListenerpublic 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
 
 - 
canChangeVisibilitypublic boolean canChangeVisibility() Description copied from interface:LayerContentChecks whether we can change the visibility of this layer.- Specified by:
- canChangeVisibilityin interface- LayerContent
- Returns:
- true if we can change this layer's visibility; false otherwise
 
 - 
isVisiblepublic boolean isVisible() Description copied from interface:LayerContentChecks if this layer is visible or not.- Specified by:
- isVisiblein interface- LayerContent
- Returns:
- true if the layer is visible; false otherwise
- See Also:
- LayerContent.setVisible(boolean)
 
 - 
setVisiblepublic void setVisible(boolean visible) Description copied from interface:LayerContentSets the layer's visibility ifLayerContent.canChangeVisibility()returns true.- Specified by:
- setVisiblein interface- LayerContent
- Parameters:
- visible- true to make the layer visible; false to hide it
- See Also:
- LayerContent.isVisible()
 
 - 
isVisibleAtScalepublic boolean isVisibleAtScale(double scale) Description copied from interface:LayerContentChecks 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:
- isVisibleAtScalein 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
 
 - 
canShowInLegendpublic boolean canShowInLegend() Description copied from interface:LayerContentChecks if this layer will be listed in the legend.- Specified by:
- canShowInLegendin interface- LayerContent
- Returns:
- true if this layer will be visible in the legend; false otherwise
 
 - 
setCanShowInLegendpublic void setCanShowInLegend(boolean canShowInLegend) Description copied from interface:LayerContentSets whether or not this layer should be visible in the legend.- Specified by:
- setCanShowInLegendin interface- LayerContent
- Parameters:
- canShowInLegend- true to show in the legend; false to omit it from the legend
 
 - 
getSubLayerContentspublic ListenableList<LayerContent> getSubLayerContents() Description copied from interface:LayerContentReturns 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:
- getSubLayerContentsin interface- LayerContent
- Returns:
- a read only list of sub-layers, if any
 
 - 
fetchLegendInfosAsyncpublic ListenableFuture<java.util.List<LegendInfo>> fetchLegendInfosAsync() Description copied from interface:LayerContentAsynchronously fetches a list of legend information for this layer, if any.- Specified by:
- fetchLegendInfosAsyncin interface- LayerContent
- Returns:
- a listenable future that can be used to get the legend information. Null is returned if an error occurs.
 
 - 
getLoadStatuspublic LoadStatus getLoadStatus() Description copied from interface:LoadableReturns theLoadStatusof the loadable resource.- Specified by:
- getLoadStatusin interface- Loadable
- Returns:
- the LoadStatus of the loadable resource
 
 - 
getLoadErrorpublic ArcGISRuntimeException getLoadError() Description copied from interface:LoadableReturns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOADstate, either due to calling theLoadable.loadAsync()orLoadable.retryLoadAsync()method.If the resource subsequently transitions to LoadStatus.LOADED(for example, if a call toretryLoadAsynccompletes successfully) the error is cleared out.- Specified by:
- getLoadErrorin interface- Loadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
         LoadStatus.FAILED_TO_LOADstate.
 
 - 
loadAsyncpublic void loadAsync() Description copied from interface:LoadableLoads the metadata of the loadable resource asynchronously.The load status changes from LoadStatus.NOT_LOADEDtoLoadStatus.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_LOADand 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.LOADINGstate) whenloadAsyncis 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.LOADEDorLoadStatus.FAILED_TO_LOADstate) whenloadAsyncis called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling loadAsyncon 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.LOADINGstate) can be cancelled by callingLoadable.cancelLoad().
 - 
retryLoadAsyncpublic void retryLoadAsync() Description copied from interface:LoadableLoads 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:
- retryLoadAsyncin interface- Loadable
 
 - 
cancelLoadpublic void cancelLoad() Description copied from interface:LoadableCancels 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.LOADINGstate) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADINGtoLoadStatus.FAILED_TO_LOADstate. 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.LOADINGstate.- Specified by:
- cancelLoadin interface- Loadable
 
 - 
addDoneLoadingListenerpublic void addDoneLoadingListener(java.lang.Runnable listener) Description copied from interface:LoadableAdds 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:
- addDoneLoadingListenerin interface- Loadable
- Parameters:
- listener- a Runnable that is invoked upon completion of the load operation
 
 - 
removeDoneLoadingListenerpublic boolean removeDoneLoadingListener(java.lang.Runnable listener) Description copied from interface:LoadableRemoves a done loading listener from the loadable resource.- Specified by:
- removeDoneLoadingListenerin interface- Loadable
- Parameters:
- listener- the listener to be removed
- Returns:
- true if the listener was removed, otherwise false
 
 - 
addLoadStatusChangedListenerpublic void addLoadStatusChangedListener(LoadStatusChangedListener listener) Description copied from interface:LoadableAdds aLoadStatusChangedListenerto 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:
- addLoadStatusChangedListenerin interface- Loadable
- Parameters:
- listener- the- LoadStatusChangedListenerto be added
 
 - 
removeLoadStatusChangedListenerpublic boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener) Description copied from interface:LoadableRemoves aLoadStatusChangedListenerfrom the loadable resource.- Specified by:
- removeLoadStatusChangedListenerin interface- Loadable
- Parameters:
- listener- the- LoadStatusChangedListenerto be removed
- Returns:
- true if the listener was removed, otherwise false
 
 
- 
 
-