Baidu map about geocoding and anti-geocoding

Source: Internet
Author: User
map of Baidu--geo-coding and anti-geocoding

One Goal,one Passion!


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--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) {
                } 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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.