Baidu converts longitude and latitude to address

Source: Internet
Author: User
1/** 2 * use Baidu to convert the longitude and latitude information to address information. 3*4 * @ Param longpolling longitude 5 * @ Param latitude Latitude 6 * @ Param coordtype coordinate system: <br/> 7 * <ul> 8 * <li> bd09ll Baidu mocato coordinate </LI> 9 * <li> gcj02ll mocato coordinate </LI> 10 * <li> wgs84ll GPS longitude and latitude </LI> 11 * </ul> 12 * @ return visit Baidu, the obtained address information (in JSON format) 13 */14 public static dbobject requestrelocacion (double longpolling, double latitude, string coordtype) {15 return requestrelocacion (string. valueof (longitud E), String. valueof (latitude), coordtype ); 16} 17 18/** 19 * use Baidu to convert the longitude and latitude information to address information 20*21 * @ Param longpolling longitude 22 * @ Param latitude 23 * @ Param coordtype coordinate system: <br/> 24 * <ul> 25 * <li> bd09ll Baidu mocato coordinate </LI> 26 * <li> gcj02ll mocato coordinate </LI> 27 * <li> wgs84ll GPS longitude and latitude </LI> 28 * </ul> 29 * @ return visit Baidu, URL Information obtained (in JSON format) 30 */31 public static dbobject requestrelocacion (string longpolling, string latitude, string coordtype) {3 2 dbobject retjson = NULL; 33 string requsturl = "http://api.map.baidu.com/geocoder/v2? Ak = 7049808f066b5beb3cf2c7c781277583 & coordtype = "+ coordtype + 34" & location = "+ latitude +", "+ longpolling +" & Output = JSON "; 35 string requestresult = sendrequest (requsturl); 36 try {37 retjson = (dbobject) JSON. parse (requestresult )). get ("result"); 38} catch (exception e) {} 39 40 return retjson; 41} 42

Running result:

1 public static void main (string [] argv) {2 dbobject OBJ = requestrelocacion ("116.46", "39.92", "wgs84ll"); 3 system. out. println (OBJ); 4 // print the result as follows: 5/* {6 "location": {7 "LNG": 116.47274785743, 8 "Lat": 39.927001495651 9 }, 10 "formatted_address": "No. 12, lane A, xili, Hujia building, Chaoyang District, Beijing", 11 "business": "Hujia building, jingguang bridge, tuanjie Lake", 12 "addresscomponent ": {13 "city": "Beijing", 14 "District": "Chaoyang District", 15 "Province": "Beijing", 16 "street": "hujialou sisily 7 Lane ", 17 "street_number": "Jia 12" 18}, 19 "citycode": 13120} */21}

 

Baidu converts longitude and latitude to address

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.