Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

share|improve this answer
Thank you. I also found same project "MyWaterSample" from Esri which does reverse geocoding. – Jacky Nguyen Jul 15 '13 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 Jul 17 '13 at 4:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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