Skip To Content

Search for Places

In this topic


Geocoding is the process of transforming a description of a location—such as a pair of coordinates, an address, or a name of a place—to a location on the earth's surface. The resulting locations are output as geographic features with attributes, which can be used for mapping or spatial analysis.

You can quickly find various kinds of locations through geocoding. The types of locations that you can search for include points of interest or names from a gazetteer, like mountains, bridges, and stores; coordinates based on latitude and longitude or other reference systems, such as the Military Grid Reference System (MGRS) or the U.S. National Grid system; and addresses, which can come in a variety of styles and formats, including street intersections, house numbers with street names, and postal codes.

More information about what geocoding can be used for can be found here.


The Android API provides a Locator class to geocode and reverse geocode locations using ArcGIS Server Geocoding services and local, on-board data. Geocode services are based on address locators. Address locators may reside in an ArcGIS Geodatabase or as *.loc files on disk. They rely on GIS datasets and other reference data to find addresses and locations. Each address locator uses an address style for parsing addresses and standardizing them into well-structured address components.

New address locators can be created using ArcMap or ArcCatalog. You can then publish them as Geocode services using ArcMap or ArcCatalog, or using ArcGIS Server’s Manager web application. Similarly, for offline usage, ArcMap or ArcCatalog can be used to export locators to an ArcGIS Runtime format. The resulting *.plbs, *.loc, and *.lox files can then be copied to an Android device and used directly through the Locator Android API.

ArcGIS Online World Geocoding service is accessible on the web as a REST web service. The REST web service supports multiple geocoding operations including Find, Find Address Candidates, and Reverse Geocoding. The online Locator in the ArcGIS API for Android uses these operations to bring Geocoding to an Android device.

Creating a Locator

Choosing the right type of Locator depends on your data availability and needs. Offline geocoding offers the benefits of increased performance and removes the need for network connectivity, but as a consequence, a significant amount of storage space may be needed on-device. An online Locator allows you to take advantage of robust ArcGIS Online services and requires no additional data deployment, but network speeds and REST response size can negatively impact performance.

Creating an Online Locator

To instantiate a Locator using an online service, you need to provide a URL to a Geocode service REST endpoint. This URL is usually of the form:


The URL then simply has to be passed into the online creation method as shown below. If the Geocode service is secured, user credentials may also be supplied.

String url = "";
Locator locator = Locator.createOnlineLocator(url);

If no URL is provided, the online Locator will default to the World Geocoding service.

Creating a Local Locator

To instantiate a Locator using data present on-device, you must provide the path to the .loc file. The .locb and .lox files, which are also generated from the export process in ArcGIS Desktop, must be present in the same directory as the .loc file. The following snippet assumes you have a locator named “SanDiego” in the /<external-storage-directory>/ArcGIS/Geocoding/ folder on your device.

String extern = Environment.getExternalStorageDirectory().getPath();
Locator locator = Locator.createLocalLocator(extern + "/ArcGIS/Geocoding/SanDiego.loc")

Usage Considerations

Loading a local Locator can take a significant amount of time depending on the size and type of the locator present. It is recommended that a local Locator be only created once, and kept alive for the remainder of the application.

Geocoding an address

To find matching locations for an address, you must provide a LocatorFindParameters object containing the address in a format expected by the service. The find(LocatorFindParameters) method is used for single field geocoding and supports the following types of locations:

  • Street address: 380 New York St, Redlands, CA 92373
  • Administrative place names: Seattle, Washington
  • Postal codes: 92573 USA
  • Points of Interest (POI) and businesses: Yankee Stadium

Setting up the Locator Parameters for single field geocoding:

// create Locator parameters from single line address string
LocatorFindParameters findParams = new LocatorFindParameters("380 New York St. Redlands CA 92373");
// set the search country to USA, max locations to 2, 
// and output spatial reference to match the map

Run your task as an Android AsyncTask to perform a background operation. The below assumes a subclass of AsyncTask named Geocoder.

// execute async task to geocode address
new Geocoder().execute(findParams);

Here is an example of the doInBackground() method for the above:

protected List<LocatorGeocodeResult> doInBackground(LocatorFindParameters... params) {   
    // Execute the find call
    List<LocatorGeocodeResult> results = null;  
    try {        
        results = locator.find(params[0]);
    } catch (Exception e) {
    // return the resulting point(s)
    return results;

Geocoding results

Once you have successfully geocoded an address, you will most likely want to view the results on a map. Overriding your AsyncTask onPostExecute() method will allow you to invoke the UI thread after the background geocoding execution has completed.

protected void onPostExecute(List<LocatorGeocodeResult> results){
    if(results == null || results.size() == 0){
        // update UI with notice that no results were found
        Toast.makeText(GeocodeActivity.this, "No result found.", Toast.LENGTH_LONG).show();
    } else {
        // Results are returned in the best-matching order; grab the first one
        LocatorGeocodeResult result = results.get(0);
        // Get the returned geometry, create a Graphic from it, and add to GraphicsLayer
        Geometry resultLocGeom = result.getLocation();
        SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol(Color.BLUE, 20, STYLE.CIRCLE);
        Graphic resultLocation = new Graphic(resultLocGeom, resultSymbol);
        // Create a text symbol for return address with a slight offset
        TextSymbol resultAddress = new TextSymbol(16, result.getAddress(), Color.BLACK);
        // Create a graphic object for address text, and add to GraphicsLayer
        Graphic resultText = new Graphic(resultLocGeom, resultAddress);
        // Zoom to the Geocoding result
        mMapView.zoomTo(resultLocGeom, 10);