Skip to content

Display overview map

View on GitHubSample viewer app

Include an overview or inset map as an additional map view to show the wider context of the primary view.

Image of display overview map

Use case

An overview map provides a useful, smaller-scale overview of the current map view's location. For example, when you need to inspect a layer with many features while remaining aware of the wider context of the view, use an overview map to help show the extent of the main map view.

How to use the sample

Pan or zoom across the map view to browse through the tourist attractions feature layer and notice the viewpoint and scale of the linked overview map update automatically.

How it works

  1. Create States to hold the current viewpoint and current visible area of the map.
  2. Instantiate a FeatureLayer to display the tourist attraction features.
  3. Create an ArcGISMap object, set its initialViewpoint to the initial value of the viewpoint State, and add the FeatureLayer into its operationalLayers.
  4. In the user-interface, declare a MapView to display the ArcGISMap. Use onViewpointChangedForCenterAndScale and onVisibleAreaChanged to keep the viewpoint and visible area States up to date.
  5. In the user-interface, declare an OverviewMap object from the ArcGIS Maps SDK Toolkit. Set its viewpoint and visibleArea to the previously created States.

Relevant API

  • ArcGISMap
  • MapView
  • OverviewMap

About the data

The data used in this sample is the OpenStreetMap Tourist Attractions for North America feature layer, which is scale-dependent and displays at scales larger than 1:160,000.

Additional information

This sample uses the overview map toolkit component. For information about setting up the toolkit visit the developer guide doc.

Tags

context, inset, map, minimap, overview, preview, small scale, toolkit, view

Sample Code

DisplayOverviewMapViewModel.ktDisplayOverviewMapViewModel.ktMainActivity.ktDisplayOverviewMapScreen.kt
Use dark colors for code blocksCopy
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 /* Copyright 2025 Esri  *  * Licensed under the Apache License, Version 2.0 (the "License");  * you may not use this file except in compliance with the License.  * You may obtain a copy of the License at  *  * http://www.apache.org/licenses/LICENSE-2.0  *  * Unless required by applicable law or agreed to in writing, software  * distributed under the License is distributed on an "AS IS" BASIS,  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  * See the License for the specific language governing permissions and  * limitations under the License.  *  */  package com.esri.arcgismaps.sample.displayoverviewmap.components  import android.app.Application import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.viewModelScope import com.arcgismaps.data.ServiceFeatureTable import com.arcgismaps.geometry.Polygon import com.arcgismaps.mapping.ArcGISMap import com.arcgismaps.mapping.BasemapStyle import com.arcgismaps.mapping.Viewpoint import com.arcgismaps.mapping.layers.FeatureLayer import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel import kotlinx.coroutines.launch  class DisplayOverviewMapViewModel(app: Application) : AndroidViewModel(app) {   private val initialViewpoint = Viewpoint(latitude = 50.431999, longitude = -104.607293, scale = 10e3)   // the current viewpoint of the map  var viewpoint by mutableStateOf(initialViewpoint)  // the current visible area of the map  var visibleArea: Polygon? by mutableStateOf(null)   // set up feature layer  private val touristAttractionsUrl =  "https://services6.arcgis.com/Do88DoK2xjTUCXd1/arcgis/rest/services/OSM_NA_Tourism/FeatureServer/0"  private val touristAttractionsTable = ServiceFeatureTable(touristAttractionsUrl)  private val featureLayerTouristAttractions = FeatureLayer.createWithFeatureTable(touristAttractionsTable)   // the map used by MapView  val arcGISMap = ArcGISMap(BasemapStyle.ArcGISTopographic).apply {  initialViewpoint = viewpoint  // add tourist attractions feature layer to the map  operationalLayers.add(featureLayerTouristAttractions)  }   // Create a message dialog view model for handling error messages  val messageDialogVM = MessageDialogViewModel()   init {  viewModelScope.launch {  arcGISMap.load().onFailure { messageDialogVM.showMessageDialog(it) }  }  } }

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