There are two common roles for layers:
- Basemap layers - provide context (a background) for your data
- Operational layers - the map data actively in use
For example, a map of a utility network might show pipes in an operational layer and a street map background (basemap) to make it clear which houses those pipes serve.
If you want to quickly visualize data that's available to your app, but don't want to store it in an ArcGIS portal or a layer, consider using graphics.
Maps and scenes expose an operational layers property, which is a collection of layers. You can add and remove layers from the map's operational layers.
// Append existing Layer object to list of layers in the map
// Remove one Layer object at a index 0 in the list of layers in the map
// Remove a specific Layer object from the list of layers in the map
Basemaps exposes a 'base layers' property, which contains all of the layers in the basemap. The can be accessed through the basemap on maps and scenes. Note that using a basemap for all your maps is recommended, when a suitable one is available. Some examples of basemaps that can be created using static factory methods are:
- World imagery
- World streets
- National geographic
- World navigation (vector)
- World streets (vector)
Adding a layer to muliple maps or scenes
A layer can be added only once to a single map or scene. If you add a layer already in one map or scene to another map or scene then an exception will be thrown with the message: object is already owned (see ArcGIS Runtime errorsTo use the same layer in more than one map or scene you have a few options:
There is no copy/clone method for a Layer object in the current release of the ArcGIS Runtime SDK for Qt. It may be added in a future release.
- Create a new layer from the original source data. This requires accessing the underlying data source twice. For example, in the case of layers made from an online source, it would mean accessing the associated service twice.
- If the layer is no longer required in the first map or scene, remove the layer from the first map or scene and add it to the second map or scene.