Geocode tasks (AGS Locator)
Sample design
This sample has a MapView, which has two layers: TiledMapServiceLayer and GraphicLayer. The TiledMapServiceLayer points to a map service on one of Esri's servers, while the GraphicsLayer holds graphic elements that display a location corresponding to an entered address. When the sample application starts, a MapView, TiledMapServiceLayer, and GraphicsLayer are instantiated; a single tap listener is added to the map view; and Android user interface (UI) elements (such as AlertDialog, Button) are instantiated.
When an address is entered, geocoding is executed asynchronously. A graphic is added to the graphic layer and is displayed along with locator results on the map. When the map is tapped, reverse geocoding is executed, and a callout is instantiated and displayed, which includes details of the matching address.
Using the sample
- Launch the sample on your device.
- Enter an address in the Address, City, State, Zip format and press the Locate button.
The matching location is displayed on the map along with the address. If a ZIP Code is not entered, the task still executes with the appropriate ZIP location.
- Tap the map once to get the matching location in a callout.