View inMAUIWinUIWPF View on GitHub Sample viewer app

Show predefined popups 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 a Map using a URL.
  2. Set the map to a MapView and listen for its GeoViewTapped event.
  3. Use the GeoView.IdentifyLayerAsync() method to identify the top-most feature.
  4. Set the first Popup from the result’s IdentifyLayerResult.Popups collection on a PopupViewer.
  5. Display the popup viewer.

Relevant API

  • IdentifyLayerResult
  • Map
  • PopupViewer

About the data

The California Peaks layer contains point features for every mountain peak in California with an elevation that exceeds 14,000 feet (4,267.2 meters) above mean sea level. Each feature contains a predefined popup with information about its associated peak, including an image, chart, and feature table data.

Tags

feature, feature layer, popup, web map

Sample code

ShowPopup.xaml.csShowPopup.xaml.csShowPopup.xaml
// 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.
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Mapping.Popups;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace ArcGIS.WPF.Samples.ShowPopup
{
[ArcGIS.Samples.Shared.Attributes.Sample(
name: "Show popup",
category: "Data",
description: "Show predefined popups from a web map.",
instructions: "Tap on the features to prompt a popup that displays information about the feature.",
tags: new[] { "feature", "feature layer", "popup", "web map" })]
public partial class ShowPopup
{
private FeatureLayer _featureLayer;
private bool _isIdentifying;
public ShowPopup()
{
InitializeComponent();
_ = Initialize();
}
private async Task Initialize()
{
try
{
// Create and load the web map that contains predefined popups.
Map map = new Map(new Uri("https://arcgisruntime.maps.arcgis.com/home/item.html?id=9f3a674e998f461580006e626611f9ad"));
await map.LoadAsync();
// Get the layer whose features define the popups.
_featureLayer = map.OperationalLayers.OfType<FeatureLayer>().First();
// Listen for taps after the map and its operational layer are ready.
MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;
MyMapView.Map = map;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
{
if (_featureLayer == null || _isIdentifying) return;
_isIdentifying = true;
try
{
// Identify the first feature at the tapped location and request its predefined popup.
_featureLayer.ClearSelection();
IdentifyLayerResult result = await MyMapView.IdentifyLayerAsync(_featureLayer, e.Position, 12, false);
if (result.GeoElements.FirstOrDefault() is not Feature feature ||
result.Popups.FirstOrDefault() is not Popup popup)
{
PopupViewer.Popup = null;
PopupBackground.Visibility = Visibility.Collapsed;
return;
}
// Select the identified feature and display its popup.
_featureLayer.SelectFeature(feature);
PopupViewer.Popup = popup;
PopupBackground.Visibility = Visibility.Visible;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
finally
{
_isIdentifying = false;
}
}
private void PopupBackground_MouseDown(object sender, MouseButtonEventArgs e)
{
if (!ReferenceEquals(e.OriginalSource, PopupBackground)) return;
PopupBackground.Visibility = Visibility.Collapsed;
PopupViewer.Popup = null;
_featureLayer?.ClearSelection();
}
}
}