View on GitHub Sample viewer app

Show a predefined popup from a web map.

Show popup screenshot

Use case

Many web maps contain predefined popups which are used to display the attributes associated with each feature layer in the map, such as hiking trails, land values, or unemployment rates. You can display text, attachments, images, charts, and web links. Rather than creating new popups to display information, you can easily access and display the predefined popups.

How to use the sample

Tap on the features to prompt a popup that displays information about the feature.

How it works

  1. Create and load an ArcGISMap using a URL.
  2. Create a MapViewProxy and set it to the composable MapView.
  3. Use the mapViewProxy.identify(...) function to identify the top-most feature.
  4. From the identified feature get the Popup.
  5. Pass the Popup to the composable Popup to display it.

Relevant API

  • ArcGISMap
  • IdentifyLayerResult
  • Popup

About the data

This sample uses a feature layer that displays reported information about mountains in the Sierra Nevada.

Additional information

This sample uses the Popup toolkit component. For information about setting up the toolkit, as well as code for the underlying component, visit the toolkit docs.

Tags

feature, feature layer, popup, toolkit, web map

Sample Code

MainActivity.kt MainActivity.kt ShowPopupViewModel.kt ShowPopupScreen.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.showpopup
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.showpopup.screens.ShowPopupScreen
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 {
ShowPopupApp()
}
}
}
@Composable
private fun ShowPopupApp() {
Surface(color = MaterialTheme.colorScheme.background) {
ShowPopupScreen(
sampleName = getString(R.string.show_popup_app_name)
)
}
}
}