map of Baidu--geo-coding and anti-geocoding
One Goal,one Passion!
Geocoding:
Geocoding--that is, we parse the familiar address into latitude.
Address |
latlng (coordinate) |
Zhengzhou |
34.7568711, 113.663221 |
Okay, the code is simple.
New coded Query Object
GeoCoder geocode = Geocoder.newinstance ();
New Query Object The condition to query
geocodeoption geooption = new Geocodeoption (). City ("Zhengzhou"). Address ("Zhengzhou East Station");
Initiate geocoding request
Geocode.geocode (geooption);
Set query Results Listener
Geocode.setongetgeocoderesultlistener (new Ongetgeocoderresultlistener () {
/**
* Anti-geocoding Query result callback function
* @param result anti-geocoding query results */
@Override public
Void Ongetreversegeocoderesult (reversegeocoderesult result) {
}
}
/**
* geocoding Query Result callback function
* @param result geocoding Query Results
*
/@Override public
void Ongetgeocoderesult (geocoderesult result) {
SYSTEM.OUT.PRINTLN ("geocoding Query Results" + result.getlocation ());}
);
Anti-geocoding:
Anti-geocoding--is to resolve the latitude and longitude coordinates to a location that we can understand. For example:
latlng (coordinates) |
address |
34.7568711, 113.663221 |
Zhengzhou |
New coded Query Object geocode = Geocoder.newinstance ();
New Query object conditions to query reversegeocodeoption options = new Reversegeocodeoption (). location (ll);
Initiate an anti-geocoding request Geocode.reversegeocode (options); Set Query Results Listener Geocode.setongetgeocoderesultlistener (new Ongetgeocoderresultlistener () {/** * anti-geocoding query knot The callback function * @param result anti-geocoding query results */@Override public void Ongetreversegeocoderesult (Reve
Rsegeocoderesult result) {if (result = = NULL | | Result.error! = SearchResult.ERRORNO.NO_ERROR) {
Return
} if (Result! = NULL && Result.error = = SearchResult.ERRORNO.NO_ERROR) {//Get location
Address = result.getaddress ();
System.out.println ("Get position" + address);
}}/** * geocoding query result callback function * @param result geocoding Query results */@Override public void Ongetgeocoderesult (Geocoderesult result) {}});
Baidu Map address coding and anti-coding has been completed, really very simple oh!