Maps and layers
In this topic
A map is a canvas that draws layers of geographic data. Different layer types are used to draw different data types. For example, you may have data that is provided by a service or from local files; the data might be static in nature, or change over time. Maps can also show information relating to the map and its layers, such as GPS locations, and pop-ups.
MapView is a control that acts as a container for a
MapView can contain a single
Map and a
Map may contain zero or several layers. This architecture allows you to take advantage of the
MVVM design pattern by defining your map as a property on a
ViewModel class and binding it to the
MapView.Map property in your
To enable the workflows your app requires, and to maximize display performance, always consider the factors below when you create your map.
Layers can generally be thought of as basemaps, operational, or graphics layers, depending on the data they display and how they are used, with each type of layer offering different functionality and performance characteristics.
- Background data that provides context and does not change often is generally considered as the basemap, for example, topography, imagery, streets, or buildings data. Basemap data is generally prepared and cached on a server as ready-to-access image tiles that are efficient to request and display in an app. ArcGIS Online provides a free set of ready-to-use basemap layers that are pre-rendered and cached to ensure they draw quickly. Alternatively, you can use the ArcGIS platform to create your own basemaps. For details on functionality and performance, see Basemap layers in the Layer types topic. For details on using offline basemaps, see Create an offline map.
- Data edited by app users, periodically changing data, or data resulting from analyses, may best be considered as operational layers. Typically, operational data is created and maintained by your organization. Displaying or working with operational data is often the main focus of an app. For details on functionality and performance and how to take operational layers offline, see Operational layers in the Layer types topic.
- Live, rapidly changing, ephemeral data may be appropriate for a graphics layer. For example, vehicle or workforce locations, geotriggered events, or temporary query results. Graphics are generated in memory in an app, or created in an app based on an external information feed. For details on functionality and performance, see Graphics layers in the Layer types topic.
Other types of specialized layers provide the ability to add a wide range of data and services to a map, for example WMS services and OpenStreetMap.
A wide variety of layer classes are provided by the API. Each can be used to display a specific data type, and each has its own functionality and performance characteristics. Generally, each layer class is used for basemap, operational, or graphics layers. However, these are not absolute rules, and the choice of class should be based on an understanding of the characteristics of each type. For information on the functionality and performance of different types of layers, see Layer Types.
The layer order in a map is important. Basemaps typically cover the entire surface of the map. They are added to the map first so that they draw under the layer and do not obscure other layers. Layers can be re-ordered, but this will not change the map's spatial reference.
Add operational layers to the map next. Graphics layers are typically added last and show on top of all other layers.
Maps and layers use spatial references to help define where coordinates are located on the earth's surface. Distance units and coordinates of map operations are determined by the spatial reference of the map. The first layer in a map, typically the basemap, defines the spatial reference of the map, and this cannot be changed.
If the spatial reference of layers in a map are different to the spatial reference of the map, the layers must be reprojected to the spatial reference of the map before displaying. Some layer types cannot be re-projected, for example, tiled map layer services draw and cache on a server, and cannot be changed on the client.
To maximize performance, avoid reprojection entirely by ensuring all layers have the same spatial reference as the map.
Choose how to author a map
You can author a map in ArcGIS Online, add the data layers you require, define how the layers should appear, and use this map in your app.
This allows you to interactively experiment with many aspects of the appearance and behavior of the map layers, and immediately view your changes online. By loading an online map in your app, you also gain the advantage of a centrally managed map, with the ability to change the map online independent of your application code, reducing the need for application redeployment. It is also easier to offer the user a choice of pre-defined online maps to open using the Portal API. Note that online maps may only contain online data.
Alternatively, you can build a map by defining and adding layers at runtime programmatically, or even add code to allow your users to add their layers. You can also make temporary changes to a map that you created online, by adding or removing layers, and changing a layer's appearance. This approach enables you to add offline layers to your map, and offers the flexibility of programmatic control, but lacks the centralized maintainable map.
It is not possible to directly load map package (MPK) files or map documents saved from ArcGIS for Desktop into the map.
Behavior at runtime
Also consider how the map draws and behaves at runtime, and how the user interacts with it.
Map and layer initialization
Maps are initialized asynchronously after being created. Layers are also initialized asynchronously when added to the map. Attempting to access certain properties or operations of the map or its layers before they are initialized may throw errors. For example, getting the spatial reference or center of a map, or the name or extent of a layer. You can handle the
LayerLoaded event on the
MapView to know if (and when) each layer is loaded successfully into the map. You can also await the
LayersLoadedAsync method to get the status of all layers after the map view attempts to load them. It's also good practice to set the initial extent of the map to ensure the user starts in a location relevant to the map's usage.
The following code example uses the
LayersLoadedAsync method to await the loading of all the map's layers. After loading is attempted for all layers, the
InitializationException property will be populated for layers that encountered an exception while loading (otherwise, the property will contain
null). The following code would be called in the constructor for the page.
private async Task TryLoadLayers()
var builder = new StringBuilder();
foreach (var layer in MyMapView.Map.Layers)
if (layer.InitializationException != null)
// report layer initialization exception messages here ...
Most flat representations of the world only extend to 180 degrees east and west longitude, the approximate location of the international date line, making it more difficult to visualize routes or shapes that cross the pacific ocean. However, the map can be configured to display the eastern and western hemispheres wrapping around each other and forming a continuous surface, giving the impression that the map is endless. Panning a map becomes similar to spinning a globe.
Navigation and interaction
Consider what actions or gestures you enable to allow users to zoom, pan, and rotate the map. The
MapView provides map navigation out-of-the-box using actions such as mouse clicks and drags, rolling the mouse wheel, and using touch gestures. This built-in behavior allows users to pan and zoom map contents and explore attributes of individual features.
Geographic data can change over time; therefore, some layers may show stored temporal data, which is information about the changing state of a dataset over time. For example, the progression of a hurricane changes in sea temperature, destruction of wildlife habitat, or the spread of disease. These layers are called time-aware layers.
You can configure a map with time-aware layers to display different periods of time. Stepping through time in your map can help you easily identify trends and patterns in the data that may have otherwise remained unnoticed. See the temporal renderer section of the Symbols and renderers topic for information about displaying temporal data on the map.