Popup In Web Map For Viewing Sample
A popup is associated with a specific layer in a web map and describes how information about features in that layer should be presented.This sample demonstrates how to display popups for a dynamic map service layer and a non-editable feature service layer in a web map. It also shows how to set properties such as background color, text color, and selector color for popup.
Sample Design
Tapping on the map to query each feature layer and each sub-layer of each dynamic map service layer. The queries are executed in asynchronous tasks. A PopupView is created for each selected graphic by feeding in the graphic and the associated popup definition that is represented by a PopupInfo object. Then add the PopuViews to the PopupContainer and display the PopupContainer in a custom Dialog.
The query upon a feature layer is performed by hit test while the query upon a sub-layer of a dynamic map service layer is through a QueryTask. For the sake of performance, a feature layer or a sub-layer which is not associated with a popup definition or not visible or not within the current scale range will not be queried.
A popup's properties such background color, text color, and selector color can be set through the PopupContainer. The setting in the PopupContainer will affect all the PopupView in the PopupContainer. If a property is not set, a default value will be used.
The Popup samples depend on the Andriod Support Library. Instructions for setting that it up prior to running the app is detailed below.
Using the Sample
- Create a new Sample project for PopupWebMapForViewing. Refer to the How to work with samples documents to create a new sample project.
- Right click the sample project and select Android Tools > Add Support Library
- Accept packages to install and click Install
- Under Android Dependencies you should see the android-support-v4.jar file library
- Right click the sample project and select Properties
- Select the Java Build Path on the left hand side then select Order and Export in the Java Build Path tabs
- Make sure Android Dependencies is checked
- Run the application
- The Popup for Viewing sample is intended to display popups but not allow for user interaction through editing them. Once map is loaded tap on a graphic to see the resulting popups.
- Tap on the map to execute queries. A popup window with one or more popups will be displayed. When multiple popups are presented, swap through or tap on the numbers at the bottom to switch popups.