欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
java根據地址從百度API獲取經(jīng)緯度
代碼:

package com.pb.baiduapi;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/** 
* 獲取經(jīng)緯度
* @author jueyue 返回格式:Map<String,Object> map map.put("status", 
* reader.nextString());//狀態(tài) map.put("result", list);//查詢(xún)結果 
* list<map<String,String>> 
* 密鑰:f247cdb592eb43ebac6ccd27f796e2d2 
*/ 
public class GetLatAndLngByBaidu { 
/** 
* @param addr 
* 查詢(xún)的地址 
* @return 
* @throws IOException 
*/ 
public Object[] getCoordinate(String addr) throws IOException { 
String lng = null;//經(jīng)度
String lat = null;//緯度
String address = null; 
try { 
address = java.net.URLEncoder.encode(addr, "UTF-8"); 
}catch (UnsupportedEncodingException e1) { 
e1.printStackTrace(); 
String key = "f247cdb592eb43ebac6ccd27f796e2d2"; 
String url = String .format("http://api.map.baidu.com/geocoder?address=%s&output=json&key=%s", address, key); 
URL myURL = null; 
URLConnection httpsConn = null; 
try { 
myURL = new URL(url); 
} catch (MalformedURLException e) { 
e.printStackTrace(); 
InputStreamReader insr = null;
BufferedReader br = null;
try { 
httpsConn = (URLConnection) myURL.openConnection();// 不使用代理 
if (httpsConn != null) { 
insr = new InputStreamReader( httpsConn.getInputStream(), "UTF-8"); 
br = new BufferedReader(insr); 
String data = null; 
int count = 1;
while((data= br.readLine())!=null){ 
if(count==5){
lng = (String)data.subSequence(data.indexOf(":")+1, data.indexOf(","));//經(jīng)度
count++;
}else if(count==6){
lat = data.substring(data.indexOf(":")+1);//緯度
count++;
}else{
count++;
}
} catch (IOException e) { 
e.printStackTrace(); 
} finally {
if(insr!=null){
insr.close();
}
if(br!=null){
br.close();
}
}
return new Object[]{lng,lat}; 


public static void main(String[] args) throws IOException {
GetLatAndLngByBaidu getLatAndLngByBaidu = new GetLatAndLngByBaidu();
Object[] o = getLatAndLngByBaidu.getCoordinate("成都市天府四街");
System.out.println(o[0]);//經(jīng)度
System.out.println(o[1]);//緯度
}

}

輸出結果:104.04701
    30.548397


調用以下路徑根據經(jīng)緯度獲取地址,返回數據為JSON格式,
http://api.map.baidu.com/geocoder/v2/?ak=pmCgmADsAsD9rEXkqWNcTzjd&location=30.548397,104.04701&output=json&pois=1
返回結果:
{"status":0,"result":{"location":{"lng":104.04701001273,"lat":30.548396923974},"formatted_address":"四川省成都市武侯區天府四街","business":"","addressComponent":{"city":"成都市","district":"武侯區","province":"四川省","street":"天府四街","street_number":""},"pois":[{"addr":"四川省成都市武侯區天府四街","cp":"NavInfo","distance":"144","name":"保利·心語(yǔ)花園","poiType":"地產(chǎn)小區","point":{"x":104.04823889466,"y":30.54874673449},"tel":"","uid":"881965b85a8d8a977369d348","zip":""},{"addr":"四川省成都市武侯區天府四街","cp":"NavInfo","distance":"629","name":"逸都國際","poiType":"地產(chǎn)小區","point":{"x":104.05247889667,"y":30.547152788724},"tel":"","uid":"e49f869c4f156be9c6effb6b","zip":""},{"addr":"四川省成都市武侯區劍南大道","cp":"NavInfo","distance":"881","name":"世豪廣場(chǎng)","poiType":"地產(chǎn)小區","point":{"x":104.05252381195,"y":30.553318490823},"tel":"","uid":"a2a7b0b167a0e1997adbd206","zip":""},{"addr":"四川省成都市武侯區德賽三街","cp":"NavInfo","distance":"989","name":"顧客停車(chē)場(chǎng)","poiType":"交通設施","point":{"x":104.04942465794,"y":30.555798655385},"tel":"","uid":"d135a6e15571911483a00cfe","zip":""}],"cityCode":75}}


本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
java使用SAE中文分詞服務(wù)
java Mysql 根據經(jīng)緯度實(shí)時(shí)計算地址位置距離
JAVA讀取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本內容的方法
Java讀取FTP上的txt文件
java 下載網(wǎng)頁(yè)
JAVA網(wǎng)絡(luò )編程,基本概念與開(kāi)發(fā)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久