百度转换经纬度为地址
生活随笔
收集整理的這篇文章主要介紹了
百度转换经纬度为地址
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1 /**
2 * 通過百度轉(zhuǎn)換經(jīng)緯度為地址信息
3 *
4 * @param longitude 經(jīng)度
5 * @param latitude 緯度
6 * @param coordtype 坐標(biāo)體系:<br/>
7 * <ul>
8 * <li>bd09ll 百度墨卡托坐標(biāo)</li>
9 * <li>gcj02ll 國測局墨卡托坐標(biāo)</li>
10 * <li>wgs84ll GPS經(jīng)緯度</li>
11 * </ul>
12 * @return 訪問百度,獲取到的地址信息(json格式)
13 */
14 public static DBObject requestRelLocacion(double longitude, double latitude, String coordtype){
15 return requestRelLocacion(String.valueOf(longitude), String.valueOf(latitude), coordtype);
16 }
17
18 /**
19 * 通過百度轉(zhuǎn)換經(jīng)緯度為地址信息
20 *
21 * @param longitude 經(jīng)度
22 * @param latitude 緯度
23 * @param coordtype 坐標(biāo)體系:<br/>
24 * <ul>
25 * <li>bd09ll 百度墨卡托坐標(biāo)</li>
26 * <li>gcj02ll 國測局墨卡托坐標(biāo)</li>
27 * <li>wgs84ll GPS經(jīng)緯度</li>
28 * </ul>
29 * @return 訪問百度,獲取到的地址信息(json格式)
30 */
31 public static DBObject requestRelLocacion(String longitude, String latitude, String coordtype){
32 DBObject retJson = null;
33 String requstUrl = "http://api.map.baidu.com/geocoder/v2/?ak=7049808f066b5beb3cf2c7c781277583&coordtype=" + coordtype +
34 "&location=" + latitude + "," + longitude + "&output=json";
35 String requestResult = SendRequest(requstUrl);
36 try {
37 retJson = (DBObject)((DBObject)JSON.parse(requestResult)).get("result");
38 } catch (Exception e) {}
39
40 return retJson;
41 }
42
運行結(jié)果:
1 public static void main(String[] argv) { 2 DBObject obj = requestRelLocacion("116.46","39.92","wgs84ll"); 3 System.out.println(obj); 4 //打印結(jié)果如下: 5 /*{ 6 "location": { 7 "lng": 116.47274785743, 8 "lat": 39.927001495651 9 }, 10 "formatted_address": "北京市朝陽區(qū)呼家樓西里七巷甲12號", 11 "business": "呼家樓,京廣橋,團(tuán)結(jié)湖", 12 "addressComponent": { 13 "city": "北京市", 14 "district": "朝陽區(qū)", 15 "province": "北京市", 16 "street": "呼家樓西里七巷", 17 "street_number": "甲12號" 18 }, 19 "cityCode": 131 20 }*/ 21 }?
轉(zhuǎn)載于:https://www.cnblogs.com/Wen-yu-jing/p/4077175.html
總結(jié)
以上是生活随笔為你收集整理的百度转换经纬度为地址的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android中RelativeLayo
- 下一篇: C# - DynamicObject w