Show predefined popups from a web map.
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. The popup viewer control from the ArcGIS Toolkit currently supports label/value displays and plaintext HTML descriptions.
How to use the sample
Tap on the features to prompt a popup that displays information about the feature.
How it works
- Create and load a
Mapusing a URL. - Use a 'GeoViewTapped' event for when the user clicks on the map.
- Use the
IdentifyLayerAsyncmethod to identify the top-most feature. - Create a
PopupManagerusing thePopupfrom theIdentifyLayerResult. - Use the
PopupManagerto populate thePopupViewerUI element.
Relevant API
- IdentifyLayerResult
- Popup
- PopupManager
About the data
This sample uses a feature layer that displays reported incidents in San Francisco.
Additional information
This sample uses the PopupViewer UI control from the open source ArcGIS Runtime SDK for .NET Toolkit.
Tags
feature, feature layer, popup, toolkit, web map
Sample Code
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.ShowPopup.ShowPopup"
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"
xmlns:resources="clr-namespace:Forms.Resources"
xmlns:toolkit="clr-namespace:Esri.ArcGISRuntime.Toolkit.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Toolkit.Xamarin.Forms">
<RelativeLayout>
<esriUI:MapView x:Name="MyMapView"
BindingContext="{x:Reference Name=ResponsiveFormContainer}"
GeoViewTapped="MapViewTapped"
Style="{StaticResource MapWithFormStyle}" />
<resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer" HeightRequest="300">
<Grid>
<Label x:Name="InstructionsLabel" Text="Tap a feature to display its popup." />
<toolkit:PopupViewer x:Name="MyPopupViewer" IsVisible="False" />
</Grid>
</resources:ResponsiveFormContainer>
</RelativeLayout>
</ContentPage>