- All Implemented Interfaces:
ApiKeyResource
,JsonSerializable
,RemoteResource
,Loadable
A basemap provides a background of geographical context for the content you display in a map or scene. It provides a visual reference to help orient users and a framework on which you can overlay operational layers, perform analysis, and visualize geographic information. The content of a basemap is typically static and does not change frequently.
A basemap is composed of a collection of base layers (getBaseLayers()
) and reference layers
(getReferenceLayers()
). Base layers are displayed at the bottom of a map or scene, and
reference layers are displayed at the top, with the GeoModel.getOperationalLayers()
between them.
Typically, you construct a basemap using a basemap style:
- Use image tile basemap styles for satellite imagery and hillshade.
- Use vector tile basemap styles such as streets navigation, light gray canvas, and OpenStreetMap (OSM).
- Create custom basemap styles with your own colors, glyphs, and fonts using the ArcGIS Vector Tile Style Editor.
See BasemapStyle
for the full range of the basemap styles provided by Esri. Basemap styles allow
you to take advantage of geographically load-balanced services and monitor usage with API keys or
named users. See Basemap layers for more information.
If your app works offline, you can construct a local basemap from a tiled layer using a
TileCache
, such as a tile package (.tpk, .tpkx, .vtpk) or a compact cache, stored on the device.
- Since:
- 100.0.0
- See Also:
-
Property Summary
TypePropertyDescriptionThe load error.The load status. -
Constructor Summary
ConstructorDescriptionBasemap()
Creates a basemap.Creates a basemap with a single base layer.Basemap
(BasemapStyle basemapStyle) Creates a basemap with aBasemapStyle
.Basemap
(BasemapStyle basemapStyle, BasemapStyleParameters basemapStyleParameters) Creates a basemap from an initialBasemapStyle
with additional parameters to control settings like language.Basemap
(PortalItem portalItem) Creates a basemap with a portal item of typePortalItem.Type.WEBMAP
.Creates a basemap with collections of base and reference layers.Creates a basemap with the URL. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDoneLoadingListener
(Runnable listener) Adds a listener to the loadable resource that is invoked when loading has completed.void
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.void
Cancels loading metadata for the object.copy()
Creates a copy of this Basemap instance.static Basemap
Creates a Basemap instance from a JSON string.Gets the API key to access API key enabled services and resources in ArcGIS Online.Gets the collection of base layers in this basemap.Gets theCredential
that is set on the network-enabled resource.getItem()
Gets the portal item associated with this basemap.Gets the value of theloadError
property.Gets the value of theloadStatus
property.getName()
Gets the name of this basemap.Gets the collection of reference layers in this basemap.Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.Gets unknown data from the source JSON.Gets unsupported data from the source JSON.getUri()
Gets the URI of thisRemoteResource
.void
Loads the metadata of the loadable resource asynchronously.The load error.The load status.boolean
removeDoneLoadingListener
(Runnable listener) Removes a done loading listener from the loadable resource.boolean
Removes aLoadStatusChangedListener
from the loadable resource.void
Loads or retries loading metadata for the object asynchronously.void
Sets the API key to access API key enabled services and resources in ArcGIS Online.void
setCredential
(Credential credential) Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge.void
Sets the name of the basemap.void
setRequestConfiguration
(RequestConfiguration requestConfiguration) Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.toJson()
Serializes a Basemap to a JSON string.
-
Property Details
-
loadStatus
- Specified by:
loadStatusProperty
in interfaceLoadable
- See Also:
-
loadError
- Specified by:
loadErrorProperty
in interfaceLoadable
- See Also:
-
-
Constructor Details
-
Basemap
public Basemap()Creates a basemap. Layers need to be added to the basemap before it can be used.- Since:
- 100.0.0
-
Basemap
Creates a basemap with a single base layer.- Parameters:
baseLayer
- the Layer that serves as base layer, which can be retrieved viagetBaseLayers()
- Since:
- 100.0.0
-
Basemap
Creates a basemap with collections of base and reference layers.- Parameters:
baseLayers
- a collection of layers that serve as base layers, may be nullreferenceLayers
- a collection of layers that serve as reference layers, may be null- Since:
- 100.0.0
-
Basemap
Creates a basemap with a portal item of typePortalItem.Type.WEBMAP
.The
PortalItem
automatically loads when the Basemap loads. If the loadedPortalItem
is not a portal item of typeType.WEBMAP
, the basemap fails to load.- Parameters:
portalItem
- a web mapPortalItem
- Throws:
IllegalArgumentException
- if a null argument is passed- Since:
- 100.0.0
- See Also:
-
Basemap
Creates a basemap with the URL.If the specified URL is a portal item URL (see
PortalItem(Portal, String)
for the supported URL formats), the underlyingPortalItem
will be created and accessible throughgetItem()
.- Parameters:
webMapUrl
- the URL of the basemap, commonly the URL of a web map portal item- Throws:
IllegalArgumentException
- if the URL is null or emptyIllegalArgumentException
- if the URL does not match the basic URL types- Since:
- 100.0.0
-
Basemap
Creates a basemap with aBasemapStyle
. These basemaps are secured and access requires either an API key or a named user.- Parameters:
basemapStyle
- the basemap style- Throws:
IllegalArgumentException
- if basemapStyle is null- Since:
- 100.10.0
- See Also:
-
Basemap
Creates a basemap from an initialBasemapStyle
with additional parameters to control settings like language.These basemaps are secured and access requires either an API key or an authenticated user.
The initial state of the Basemap is
LoadStatus.NOT_LOADED
. When the Basemap is loaded the values specified in theBasemapStyleParameters
are evaluated. SeeBasemapStyleParameters
for information about the expected behavior for each parameter when the Basemap is loaded.- Parameters:
basemapStyle
- the initial basemap stylebasemapStyleParameters
- parameters that control how theBasemapStyle
is used - for example by adjusting the language used for basemap labels- Throws:
NullPointerException
- if basemapStyle is nullNullPointerException
- if basemapStyleParameters is null- Since:
- 200.3.0
- See Also:
-
-
Method Details
-
getLoadStatus
Gets the value of theloadStatus
property.- Specified by:
getLoadStatus
in interfaceLoadable
- Property description:
- Returns:
- the value of the
loadStatus
property - See Also:
-
getLoadError
Gets the value of theloadError
property.- Specified by:
getLoadError
in interfaceLoadable
- 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
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
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 interfaceLoadable
- Parameters:
listener
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
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
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
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
-
loadStatusProperty
Description copied from interface:Loadable
The load status.- Specified by:
loadStatusProperty
in interfaceLoadable
- Returns:
- the
loadStatus
property - See Also:
-
loadErrorProperty
Description copied from interface:Loadable
The load error.- Specified by:
loadErrorProperty
in interfaceLoadable
- Returns:
- the
loadError
property - See Also:
-
getApiKey
Description copied from interface:ApiKeyResource
Gets the API key to access API key enabled services and resources in ArcGIS Online.An API key is a unique long-lived access token that is used to authenticate and monitor requests to ArcGIS location services and private portal items. You can create and manage an API key using your portal when you sign in with an ArcGIS Location Platform account or an ArcGIS Online account with administrator access or a custom role that has the Generate API keys privilege. To learn how to create and manage API keys, go to the Create an API Key tutorial. You must ensure that your API key has the correct privileges to access secure resources.
In addition to setting an API key at a global level for your application using
ArcGISRuntimeEnvironment.setApiKey(String)
, you can callApiKeyResource.setApiKey(String)
on any class that implementsApiKeyResource
. When you callsetApiKey(String)
on anAPIKeyResource
, it will override the default key at the global level (the key returned byArcGISRuntimeEnvironment.getApiKey()
, in other words), enabling more granular usage telemetry and management for ArcGIS Online resources used by your app.Classes that expose an API key property by implementing APIKeyResource include:
- Specified by:
getApiKey
in interfaceApiKeyResource
- Returns:
- the API key to access API key enabled services and resources in ArcGIS Online
- See Also:
-
setApiKey
Description copied from interface:ApiKeyResource
Sets the API key to access API key enabled services and resources in ArcGIS Online.An API key is a unique key used to authorize access to specific services and resources in ArcGIS Online. It is also used to monitor access to those services. An API key is created and managed in the ArcGIS developer dashboard and is tied to a specific ArcGIS account.
In addition to setting an API key at a global level for your application using
ArcGISRuntimeEnvironment.setApiKey(String)
, you can callsetApiKey(String)
on any class that implementsApiKeyResource
. When you callsetApiKey(String)
on anAPIKeyResource
, it will override the default key at the global level (the key returned byArcGISRuntimeEnvironment.getApiKey()
, in other words), enabling more granular usage telemetry and management for ArcGIS Online resources used by your app.Classes that expose an API key property by implementing APIKeyResource include:
- Specified by:
setApiKey
in interfaceApiKeyResource
- Parameters:
apiKey
- the API key to access API key enabled services and resources in ArcGIS Online- See Also:
-
getBaseLayers
Gets the collection of base layers in this basemap.Base layers are drawn beneath all other layers in the
ArcGISMap
orArcGISScene
. They are designed to provide a visual reference to help orient the user. Aerial imagery, terrain, and streets are examples of basemap layers. The collection can be empty but it is never null.This collection is specific to this basemap so you cannot reuse a collection coming from another Basemap.
- Returns:
- the collection of base layers in this basemap
- Since:
- 100.0.0
- See Also:
-
getReferenceLayers
Gets the collection of reference layers in this basemap.Reference layers are drawn on top all other layers in the
ArcGISMap
orArcGISScene
to display information such as boundaries, labels, and traffic networks. The collection can be empty but it is never null.This collection is specific to this basemap so you cannot reuse a collection coming from another Basemap.
- Returns:
- the collection of reference layers in this basemap
- Since:
- 100.0.0
- See Also:
-
getName
Gets the name of this basemap.- Returns:
- the name of this Basemap, or an empty string if the basemap has no name.
- Since:
- 100.0.0
-
setName
Sets the name of the basemap.- Parameters:
name
- the name of this Basemap- Since:
- 100.0.0
-
getItem
Gets the portal item associated with this basemap.- Returns:
- the associated Item or null if this Basemap is not associated with an Item
- Since:
- 100.0.0
-
fromJson
Creates a Basemap instance from a JSON string.- Parameters:
json
- a JSON string that represents a Basemap- Returns:
- a Basemap instance
- Throws:
IllegalArgumentException
- if json is null or empty- Since:
- 100.0.0
-
toJson
Serializes a Basemap to a JSON string.- Specified by:
toJson
in interfaceJsonSerializable
- Returns:
- a JSON string
- Since:
- 100.0.0
-
getUnknownJson
Description copied from interface:JsonSerializable
Gets unknown data from the source JSON.Unknown JSON is a Map of values not defined in the ArcGIS specification used to create this object but found in the source JSON. If the object is written back to JSON, any unknown JSON data is not persisted. The ArcGIS specification may be for a web map, web scene, REST API, and so on.
- Specified by:
getUnknownJson
in interfaceJsonSerializable
- Returns:
- an unmodifiable Map containing unknown data from the source JSON
-
getUnsupportedJson
Description copied from interface:JsonSerializable
Gets unsupported data from the source JSON.Unsupported JSON is a Map of values defined in the ArcGIS specification used to create this object but not currently used in this API. If the object is written back to JSON, any unsupported JSON data is persisted. The ArcGIS specification may be from a web map, web scene, REST API, and so on.
- Specified by:
getUnsupportedJson
in interfaceJsonSerializable
- Returns:
- an unmodifiable Map containing unsupported data from the source JSON
-
copy
Creates a copy of this Basemap instance.The method performs a deep copy of the Basemap, i.e. all objects referenced by the Basemap, such as layers or portal item, are copied as well.
- Returns:
- a copy of this Basemap instance
- Since:
- 100.0.0
-
getUri
Description copied from interface:RemoteResource
Gets the URI of thisRemoteResource
. Typically this is the URI used to instantiate the object.- Specified by:
getUri
in interfaceRemoteResource
- Returns:
- the URI of this RemoteResource
-
getCredential
Description copied from interface:RemoteResource
Gets theCredential
that is set on the network-enabled resource.Only applicable if the resource is secured.
- Specified by:
getCredential
in interfaceRemoteResource
- Returns:
- the Credential, or null if there is none
-
setCredential
Description copied from interface:RemoteResource
Sets aCredential
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 interfaceRemoteResource
- Parameters:
credential
- the Credential to be used for authentication
-
getRequestConfiguration
Description copied from interface:RemoteResource
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.- Specified by:
getRequestConfiguration
in interfaceRemoteResource
- Returns:
- the
RequestConfiguration
used to modify network requests
-
setRequestConfiguration
Description copied from interface:RemoteResource
Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
. If not set, the globalRequestConfiguration
will be used (seeRequestConfiguration.getGlobalRequestConfiguration()
).- Specified by:
setRequestConfiguration
in interfaceRemoteResource
- Parameters:
requestConfiguration
- the RequestConfiguration used to modify network requests
-