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