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
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.ShowCallout.ShowCallout"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
<StackLayout Orientation="Vertical">
<Label Text="Tap to show a callout." VerticalOptions="Start" />
<esriUI:MapView x:Name="MyMapView" VerticalOptions="FillAndExpand" />
</StackLayout>
</ContentPage>