Maps (2D)

Maps and scenes provide interactive displays of geographic data that enable you to visualize and explore patterns, answer questions, and share insight. They can be opened, edited, and shared across the ArcGIS system and beyond. Maps are designed for interaction in two dimensions (2D) and scenes for interaction in three dimensions (3D). See Scenes (3D) in this guide for more information about working with scenes.

You can use a map to:

  • Display a basemap layer such as streets or satellite imagery.
  • Access and display data layers based on files or services, including data you have authored.
  • Provide context for temporary points, lines, polygons, or text displayed as graphics.
  • Inspect data layers and display information from attributes.
  • Measure distance and explore spatial relationships between geometries.
  • Save a collection of layers as a web map to be shared across the ArcGIS platform.

How a map works

A map works together with a map view to display geographic content in two dimensions. A map contains a collection of layers including multiple data layers from online or local sources, and a basemap layer that gives geographic context. A map can also contain datasets that enable searches for addresses or place names, networks for solving routes, utility networks for tracing the flow of services such as water and electricity, and non-spatial tables. Maps can be created, displayed, edited, and saved using ArcGIS Runtime. Because the format is based on the ArcGIS web map standard, these maps can be shared uniformly across the ArcGIS system.

For offline workflows (when you don't have network connectivity), you can open a map stored in a mobile map package. Mobile map packages can be created using ArcGIS Pro, ArcGIS Enterprise, or ArcGIS Online. See Offline maps, scenes, and data for more information about implementing offline workflows with ArcGIS Runtime.

Map

A map contains a collection of layers displayed in the order in which they were added, with the most recently added layer being displayed above existing layers. You can use the map to change the display order of layers as well as to control which layers are visible, and expose this functionality with user interface controls such as lists, check boxes, or switches. A map also contains a collection of bookmarks, which, similar to a web browser bookmark, allow you to quickly navigate to a predefined area of the map.

You can open an existing map or create one entirely with code. To create a map, you typically first add a basemap layer and then one or more data layers.

                       
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val map = ArcGISMap(BasemapStyle.ARCGIS_NAVIGATION)




private val activityMainBinding by lazy {
    ActivityMainBinding.inflate(layoutInflater)
}
private val mapView: MapView by lazy {
    activityMainBinding.mapView
}

...

mapView.map = map

val latitude = 34.0270
val longitude = -118.8050
val scale = 72000.0
mapView.setViewpoint(Viewpoint(latitude, longitude, scale))

You can also open a map stored in a portal (such as ArcGIS Online) using its URL.

Layer

Each layer in a map references geographic data, either from an online service or from a local dataset. There are different types of of layers that can be added to a map, each designed to display a particular type of data. Some layers display images, such as satellite imagery or aerial photography, while others are composed of a collection of features to represent real-world entities using point, line, or polygon geometries. In addition to geometry, features have attributes that provide details about the entity it represents.

The Layer class is the base class for all types of layers used in ArcGIS Runtime. The type of layer you create depends on the type of data you want to display. For example, to display feature data you can create a FeatureLayer that references an online service (such as a feature service) or a supported local dataset.

Add layers to a map
                                                                        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Fix blank line

ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val map = ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC)

val trailheadsLayer =
    FeatureLayer(ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0"))

val trailsLayer =
    FeatureLayer(ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0"))

val openSpacesLayer =
    FeatureLayer(ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_Styled/FeatureServer/0"))

map.operationalLayers.addAll(listOf(openSpacesLayer, trailsLayer, trailheadsLayer))



ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val scene = ArcGISScene(Basemap.createTopographic())

val trailheadsLayer =
    FeatureLayer(ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0"))

val trailsLayer =
    FeatureLayer(ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0"))

val openSpacesLayer =
    FeatureLayer(ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_Styled/FeatureServer/0"))

scene.operationalLayers.addAll(listOf(openSpacesLayer, trailsLayer, trailheadsLayer))


// --------------


ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val map = ArcGISMap(BasemapStyle.ARCGIS_NAVIGATION)
// val map = ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC)
// val map = ArcGISMap(BasemapStyle.ARCGIS_LIGHT_GRAY)
// val map = ArcGISMap(BasemapStyle.OSM_LIGHT_GRAY)



ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val map = ArcGISMap(BasemapStyle.ARCGIS_IMAGERY_STANDARD)
// val map = ArcGISMap(BasemapStyle.ARCGIS_HILLSHADE_LIGHT)
// val map = ArcGISMap(BasemapStyle.ARCGIS_HILLSHADE_DARK)



ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val portal = Portal("https://www.arcgis.com", false)

val baseLayer = ArcGISTiledLayer(PortalItem(portal, "1b243539f4514b6ba35e7d995890db1d"))

val referenceLayer =
    ArcGISVectorTiledLayer(PortalItem(portal, "d2ff12395aeb45998c1b154e25d680e5")).apply {
        opacity = 0.5f
    }

val basemap = Basemap().apply {
    baseLayers.add(baseLayer)
    referenceLayers.add(referenceLayer)
}

val map = ArcGISMap(basemap)

MapView

A map view is a user-interface control that displays a single map in your app. It contains built-in functionality that allows the user to explore the map by zooming in and out, recentering the map display, or getting additional information about elements in the map. It also manages graphics in one or more collections of graphics overlays. The graphics managed by the map view always display above all layers displayed in the map.

A map view control also allows you to:

  • Access data for data layers and graphics.
  • Display the current location as a point on the map.
  • Identify and select features at a specified location.
  • Export an image of the current display.
  • Rotate the map display.
  • Apply a time extent to filter the display of features.
  • Filter layer data using attribute and spatial criteria.

Add a map to a MapView control to display it. Changes you make to the map, such as adding, removing, or reording layers, will immediately be reflected in the map view display. The ArcGISMap.setInitialViewpoint() property will determine the area of the map shown when the map loads. You can also use MapView.setViewpoint() and MapView.setViewpointRotation() to programmatically change the map area or orientation shown in the display.

                       
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

val map = ArcGISMap(BasemapStyle.ARCGIS_NAVIGATION)




private val activityMainBinding by lazy {
    ActivityMainBinding.inflate(layoutInflater)
}
private val mapView: MapView by lazy {
    activityMainBinding.mapView
}

...

mapView.map = map

val latitude = 34.0270
val longitude = -118.8050
val scale = 72000.0
mapView.setViewpoint(Viewpoint(latitude, longitude, scale))

Examples

Create and display a map

You can display a basic map by creating one with a basemap layer, setting its initial extent, and adding it to a map view. To learn how to add additional data, see the Layers topic.

Steps

  1. Create a new ArcGISMap, passing a BasemapStyle into the constructor.
  2. Optionally, add one or more data layers to the map.
  3. Assign the map to a MapView control in your app.
  4. Set the map view Viewpoint to focus on a specified area of the map.
                               
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class MainActivity : AppCompatActivity() {

  private val activityMainBinding by lazy {
    ActivityMainBinding.inflate(layoutInflater)
  }
  private val mapView: MapView by lazy {
    activityMainBinding.mapView
  }

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(activityMainBinding.root)

    setupMap()
  }

  private fun setupMap() {

    ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

    val map = ArcGISMap(BasemapStyle.ARCGIS_NAVIGATION)

    mapView.map = map

    val latitude = 34.0270
    val longitude = -118.8050
    val scale = 72000.0
    mapView.setViewpoint(Viewpoint(latitude, longitude, scale))

  }
}

You can also create and save a web map using ArcGIS Pro or the ArcGIS Online map viewer and open it in your ArcGIS Runtime app.

Display a mobile map

This example displays a map from a mobile map package. You can create your own mobile map (or scene) packages using ArcGIS Pro or download existing ones from ArcGIS Online. The Yellowstone mobile map package, for example, shows points of interest in Yellowstone National Park.

Steps

  1. Create a MobileMapPackage using the path to a local .mmpk file.
  2. Call MobileMapPackage.loadAsync() to load the package.
  3. When the package loads, get the first map from the package using the MobileMapPackage.getMaps() property.
  4. Display the map in a MapView.
                                    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class MainActivity : AppCompatActivity() {

  private lateinit var mapPackage: MobileMapPackage

  private val activityMainBinding by lazy {
    ActivityMainBinding.inflate(layoutInflater)
  }
  private val mapView: MapView by lazy {
    activityMainBinding.mapView
  }

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(activityMainBinding.root)

    ArcGISRuntimeEnvironment.setApiKey("YOUR_API_KEY")

    loadMobileMapPackage("MMPK_FILE_PATH")
  }

  private fun loadMobileMapPackage(mmpkFile: String) {

    mapPackage = MobileMapPackage(mmpkFile).also {
      // load the mobile map package asynchronously
      it.loadAsync()
    }

    // add done listener which will invoke when mobile map package has loaded
    mapPackage.addDoneLoadingListener() {
      if (mapPackage.loadStatus === LoadStatus.LOADED && mapPackage.maps.isNotEmpty()) {
        mapView.map = mapPackage.maps[0]
      }
    }

  }
}

Use API keys

An API key can be used to authorize access to ArcGIS Online services and resources from your app, as well as to monitor access to those services. You can use a single API key for all requests made by your app, or assign individual keys for classes that expose an API key property. Refer to API keys in the security and authentication topic for details.

Tutorials

Samples

Services

Next steps

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.