View on GitHub Sample viewer app

Change a map’s basemap.

Image of Set basemap sample

Use case

A basemap draws beneath all layers on a Map or Scene and is used to provide visual reference for the operational layers. Basemaps should be selected contextually. For example, in maritime applications, it would be more appropriate to use a basemap of the world’s oceans as opposed to a basemap of the world’s streets.

How to use the sample

Open the sample and browse the basemap list shown in the bottom sheet. Tap a basemap to set it as the map’s basemap. The map updates immediately to reflect the new style.

How it works

  1. Create a Map object with the arcGISImagery basemap style.
  2. Display the map using the MapView composable from the ArcGIS Maps SDK for Kotlin Toolkit.
  3. Load BasemapStylesService to retrieve the available basemap styles.
  4. For each BasemapStyleInfo returned, create a BasemapGalleryItem and display them in the BasemapGallery Toolkit composable.
  5. When BasemapGalleryItem is tapped, update the current map’s basemap using:
    • arcGISMap.setBasemap(Basemap(basemapStyleInfo.style))

Relevant API

  • ArcGISMap
  • Basemap
  • BasemapGallery
  • BasemapGalleryItem
  • BasemapStyle
  • BasemapStyleInfo
  • BasemapStylesService
  • MapView

Additional information

Organizational basemaps are a Portal feature allowing organizations to specify basemaps for use throughout the organization. Customers expect that they will have access to their organization’s standard basemap set when they connect to a Portal. Organizational basemaps are useful when certain basemaps are particularly relevant to the organization, or if the organization wants to make premium basemap content available to their workers.

This sample uses the BasemapGallery toolkit component, which requires the ArcGIS Maps SDK for Kotlin Toolkit. The BasemapGallery toolkit component supports selecting 2D and 3D basemaps from any kind of source, such as ArcGIS Online, a user-defined portal, or a collection of Basemaps.

Tags

basemap, map

Sample Code

MainActivity.kt MainActivity.kt SetBasemapViewModel.kt SetBasemapScreen.kt
/* Copyright 2026 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.setbasemap
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
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.setbasemap.screens.SetBasemapScreen
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)
setContent {
SampleAppTheme {
SetBasemapApp()
}
}
}
@Composable
private fun SetBasemapApp() {
Surface(color = MaterialTheme.colorScheme.background) {
SetBasemapScreen(
sampleName = getString(R.string.set_basemap_app_name)
)
}
}
}