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
Best Answer
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 theMapView
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
Then implement
setOnLongPressListener
on theMapView onCreate
methodYou can find more reference on Reverse geocoding from the ArcGIS Online Geocoding Service here.