Show a callout with the latitude and longitude of user-tapped points.
Use case
Callouts are used to display temporary detail content on a map. You can display text and arbitrary UI controls in callouts.
How to use the sample
Tap anywhere on the map. A callout showing the WGS84 coordinates for the tapped point will appear.
How it works
- Listen for
GeoViewTapped
events on the map view. - When the user taps, get the tapped location from the
Location
property of theGeoViewInputEventArgs
. - Project the geometry to WGS84 using
GeometryEngine.Project
. - Create a string to display the coordinates; note that latitude and longitude in WGS84 map to the Y and X coordinates.
- Create a new callout definition using a title and the coordinate string.
- Display the callout by calling
ShowCalloutAt
on the map view with the location and the callout definition.
Relevant API
- CalloutDefinition
- GeometryEngine.Project
- GeoViewTappedEventArgs
- MapView.GeoViewTapped
- MapView.ShowCalloutAt
Tags
balloon, bubble, callout, flyout, flyover, info window, popup, tap
Sample Code
<UserControl
x:Class="ArcGISRuntime.UWP.Samples.ShowCallout.ShowCallout"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<TextBlock Text="Tap to show a callout."
FontWeight="SemiBold"
TextAlignment="Center" />
</Border>
</Grid>
</UserControl>