I am new to arcgis for android. I practice using Geocode and reverse geocode. I use sample Place Search from Esri, but i also want to add Reverse Geocode in it so that after a user put in the address and search, we put a circle graphic on the map. And if a user tap on the circle, a toast should show the street name. I have a void method called identityLocation(float x, float y). Inside that method i have:

Point aPoint = new Point(x,y);
Point mapPoint = (Point) GeometryEngine.project(aPoint, SpatialReference.create(4326), mapView.getSpatialReference());

How do return the Street name? I tried to use: locator.reverseGeocode(mapPoint, 5.0) but i was unable to. Please help me. Thanks

1 Answer 1


First, try setting the distance to 50 locator.reverseGeocode(mapPoint, 50);.

The PlaceSearch sample already does the specific feature you are trying to implement. The current implementation geocodes the address, or place, in the edit text field after you hit the Go button. Then when you click on the blue graphic representing the result a callout appears with the gecode result. Look at the setOnSingleTapListener method on the MapView to see this implementation.

Here is a simple workflow to implement reverse geocoding which returns an address to an Android Toast anywhere on the map.

Create an AsyncTask to Reverse Geocode off the UI thread

private class ReverseGeocodeTask extends
        AsyncTask {

    protected LocatorReverseGeocodeResult doInBackground(Point... params) {

        // create results object and set to null
        LocatorReverseGeocodeResult result = null;
        // set the geocode service
        locator = new Locator();
        try {

            // Attempt to reverse geocode the point.
            // Our input and output spatial reference will be the same as the map.
            SpatialReference mapRef = mMapView.getSpatialReference();
            result = locator.reverseGeocode(params[0], 50,
        } catch (Exception e) {
        // return the resulting point(s)
        return result;

    protected void onPostExecute(LocatorReverseGeocodeResult result) {

        String resultAddress = "";

        // Construct a nicely formatted address from the results
        StringBuilder address = new StringBuilder();
        if (result != null && result.getAddressFields() != null) {
            Map addressFields = result.getAddressFields();
            address.append(String.format("%s\n%s, %s %s",
                    addressFields.get("Address"), addressFields.get("City"),
                    addressFields.get("Region"), addressFields.get("Postal")));

            // Show the results of the reverse geocoding in a toast.
            resultAddress = address.toString();
            Toast toast = Toast.makeText(PlaceSearchActivity.this,
                    resultAddress, Toast.LENGTH_LONG);


Then implement setOnLongPressListener on the MapView onCreate method

mMapView.setOnLongPressListener(new OnLongPressListener() {

    private static final long serialVersionUID = 1L;

    public void onLongPress(float x, float y) {
        Point mapPoint = mMapView.toMapPoint(x, y);

        new ReverseGeocodeTask().execute(mapPoint);


You can find more reference on Reverse geocoding from the ArcGIS Online Geocoding Service here.

  • Thank you. I also found same project "MyWaterSample" from Esri which does reverse geocoding.
    – ngunha02
    Commented Jul 15, 2013 at 16:48
  • I am familiar with the MyWaterSample, the code is from the initial release and needs to be updated. The code above is the current recommended workflow.
    – jdONeill
    Commented Jul 17, 2013 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.