Skip To Content ArcGIS for Developers Sign In Dashboard

Add a layer

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.

To learn more about layer concepts, see Layers and tables. To learn about supported layer types and the details for each, see Layer types described.

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.

Operational layers

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.

Map map = new Map();
map.OperationalLayers.Add(someLayer);
map.OperationalLayers.Remove(someLayer);

Basemap layers

Basemaps exposes a 'base layers' property, which contains all of the layers in the basemap. The BaseLayers property can be accessed through the basemap property 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)

// Use the navigation basemap static method
Map map = new Map(Basemap.CreateNavigationVector());
// or
map.Basemap = Basemap.CreateNavigationVector();
// or
map.Basemap.BaseLayers.Add(someBasemapLayer);

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. To use the same layer in more than one map or scene you have a few options:

  • If you need the layer to be in two map or scene objects (or one of each!) you can add a copy of the layer to your second map or scene.
    Note:
    The copy/clone method takes deep copy of the specific layer type, rather than the Layer base class. Any changes made to the original layer will not be reflected in the copied version of the layer.
  • Create a new layer from the original source data. This is not the recommended approach because it 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.