Using Baidu Map Web Service apigeocoding API Batch address resolution

Source: Internet
Author: User
Tags call back

The Geocoding API includes address resolution and inverse address resolution capabilities:

Geocoding: That is, address resolution, from the detailed to the street of the structured address to get Baidu latitude and longitude information, such as: "Haidian District, Beijing Zhongguancun South Street, No. 27th" The result of address resolution is "lng:116.31985,lat:39.959836". At the same time, geocoding also support the historical sites, landmark building name directly analytic return Baidu latitude and longitude, for example: "Baidu Mansion" address resolution results are "lng:116.30815,lat:40.056885", general poi search requirements, the proposed use place API.

Inverse geocoding: That is, inverse address resolution, by Baidu latitude and longitude information to get structured address information, for example: "lat:31.325152,lng:120.558957" inverse address analysis results are "Jiangsu province Suzhou Huqiu District Tower Garden Road No. 318."

This article is about geocoding, reading Excel data from a local hard drive, address resolution, and saving the results to a local Excel data table.

The main code is as follows:

  

        Try{Address= Urlencoder.encode (Address, "UTF-8"); URL Resjson=NewURL ("http://api.map.baidu.com/geocoder/v2/?address=" +address+ "&output=json&ak=" +key+ "&call Back=showlocation "); BufferedReader in=NULL; if(Resjson.openstream ()! =NULL) { in=NewBufferedReader (NewInputStreamReader (Resjson.openstream ()));            } String Res; StringBuilder SB=NewStringBuilder ("");  while((Res=in.readline ())! =NULL) {sb.append (Res.trim ());            } in.close (); String Str=sb.tostring (); //System.out.println ("Return JSON:" +STR);Map<String,String> map =NULL; if(str!=NULL)            {                intLngstart = Str.indexof ("lng\": "); intLngend = Str.indexof (", \" Lat "); intLatend = Str.indexof ("},\" precise "); intPreciseend = Str.indexof (", \" confidence "); intConfidenceend = Str.indexof (", \" Level "); if(lngstart>0&&lngend>0&&latend>0) {String LNG= Str.substring (lngstart+5, Lngend); String lat= Str.substring (lngend+7, Latend); String Precise= Str.substring (latend+12, Preciseend); String confidence= Str.substring (preciseend+14, Confidenceend); Map=NewHashmap<string, string>(); Map.put ("LNG", LNG); Map.put ("Lat", LAT); Map.put ("Precise", precise); Map.put ("Confidence", confidence); returnmap; }                            }            }Catch(Exception e) {e.printstacktrace (); }                        return NULL; }

The results obtained include the longitude and latitude of the corresponding address, the accuracy of the search, and the credibility of the RBI.

  

Using Baidu Map Web Service apigeocoding API Batch address resolution

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: info-contact@alibabacloud.com 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.