免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
微信開發(fā)之如何根據(jù)經(jīng)緯度獲取所在的地點(diǎn)信息

歡迎關(guān)注微信服務(wù)號(hào):小灰熊   


package com.lwz.wx.util;

//需要導(dǎo)入的包 在網(wǎng)上都是比較容易找到的
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;






public class GetAddressbyJW {


/**
* @param args
*/


     //用來轉(zhuǎn)化URL 的 這里用的是百度的,其他的接口也都是類似的
 
public String palceRequestUrl(String lat,String lng) throws UnsupportedEncodingException { 
  
String url = "http://api.map.baidu.com/geocoder/v2/?"+ "&ak=" 
           + "百度給你的AK 需要設(shè)置為所以IP都可以用哦"+"&location="+lat+","+lng +"&output="+"json"+"&pois=0";  
return url;

}


     // 這里是獲取位置的

public String getPalace(String lat,String lng) throws Exception{ 
  String url = palceRequestUrl(lat,lng);  // 獲取完整的URL
  HttpClient client = new HttpClient();
  PostMethod getMethod = new PostMethod(url);
  client.executeMethod(getMethod);  // 用post方式提交數(shù)據(jù)

  String returnStr = getMethod.getResponseBodyAsString();//鏈接返回來的信息

         // 由于上面我們定義了接收返回的數(shù)據(jù)是JSON  所以這里需要對(duì)JSON 進(jìn)行解析

  JSONObject jsonObj = JSONObject.fromObject(returnStr );// 把接收回來的轉(zhuǎn)成json

  // System.out.println(jsonObj);                                    //可以嘗試打印出來看下是什么
        String ss= jsonObj.getString("result");                      // 這個(gè)result 就是我們需要的結(jié)果
        JSONObject jsonObj1 = JSONObject.fromObject(ss);
       // System.out.println(jsonObj1);
        // System.out.println(jsonObj1.getString("formatted_address"));
         String message=jsonObj1.getString("addressComponent");
         JSONObject jsonObj2 = JSONObject.fromObject(message);         //這里就看你需要什么了 可以自己獲取
          message=jsonObj2.getString("city");
        //  System.out.println(message);
         return message;
         


    
    }

  // 簡單的main 調(diào)用


public static void main(String[] args) {
GetAddressbyJW test=new GetAddressbyJW();
try {
String ss= test.getPalace( "26.08", "119.28");
System.out.println(ss);
 
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
 
}


}



本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
使用HttpClient通過post方式發(fā)送json數(shù)據(jù)
android JSON數(shù)據(jù)格式 解析
android與php后臺(tái)服務(wù)的數(shù)據(jù)交換例子webservice1.php
android發(fā)送/接收json數(shù)據(jù)
android 解析json數(shù)據(jù)格式
java解析json數(shù)據(jù) - Java / Web 開發(fā)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服