Geo/Reverse Geocoding
Geographic coding
Geocoding, also known as address resolution, refers to a translation service from known detailed address information to the corresponding address geographic coordinates. The sample code is as follows:
// Set the address and city to search String address="10 Dongzhimen South Street, Beijing"; String city="Beijing"; // Set parameters and return interface GeocodeSearch.searchGeocode(GeocodeSearch.GeocodeQuery.newQuery(address, city), new GeocodeSearch.GeocodeListener() { @Override public void onSuccess(GeocodeResult result) { //success } @Override public void onFail(APIStatus status) { //failure } });
GeocodeSearch.GeocodeQuery Description:
1. GeocodeSearch.GeocodeQuery.newQuery(String address, String city) constructor. Tr 2. The address parameter is an address string. The rules follow: country, province, city, district, town, town, village, street, house number, housing, building. For example: “10 Dongzhimen South Street, Beijing”. Tr 3. city is the city name keyword, for example: “Beijing”.
Note: The result return interface is an asynchronous thread interface.
Reverse Geocoding
Reverse geocoding, also known as geographic coordinate resolution, refers to the conversion of services from known geographic coordinates to corresponding address descriptions (eg, provinces, districts, floors, rooms, etc.). The sample code is as follows:
// Set the geographic coordinates of the query GeoPoint[] geoPoints=new GeoPoint[]{new GeoPoint(116.39750, 39.90850),new GeoPoint(116.43423, 39.93766)}; GeocodeSearch.RegeocodeQuery query=GeocodeSearch.RegeocodeQuery.newQuery(geoPoints); GeocodeSearch.searchRegeocode(query, new GeocodeSearch.RegeocodeListener() { @Override public void onSuccess(RegeocodeResult result) { // successful } @Override public void onFail(APIStatus status) { // failed } });
GeocodeSearch.RegeocodeQuery Description:
1. Instances can only be obtained via the newQuery (GeoPoint[] geoPoints) method in GeocodeSearch.RegeocodeQuery.
2. The parameter geoPoints is an array of GeoPoint types whose coordinates are to be inversely geocoded. It must be transmitted. It supports up to ten coordinate values. The excess is not processed.
Note: The result return interface is an asynchronous thread interface.