View on GitHub Sample 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

MainActivity.kt MainActivity.kt DisplayOverviewMapViewModel.kt DisplayOverviewMapScreen.kt
/* 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
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.esri.arcgismaps.sample.displayoverviewmap.screens.DisplayOverviewMapScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// authentication with an API key or named user is
// required to access basemaps and other location services
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
enableEdgeToEdge()
setContent {
SampleAppTheme {
DisplayOverviewMapApp()
}
}
}
@Composable
private fun DisplayOverviewMapApp() {
Surface(color = MaterialTheme.colorScheme.background) {
DisplayOverviewMapScreen(
sampleName = getString(R.string.display_overview_map_app_name)
)
}
}
}