地址解析就是將地址(如
第一種
var map = new GMap
var geocoder = new GClientGeocoder();
function showAddress(address) {
geocoder
address
function(point) {
if (!point) {
alert(
} else {
map
var marker = new GMarker(point);
map
marker
}
}
);
}
第二種方法
而通過java實現的方法如下
/**
* 利用googlemap api 通過 HTTP 進行地址解析
* @param address 地址
* @return HTTP狀態代碼
*/
private String getLatlng(String address){
String ret =
if(address != null && !address
try {
address = URLEncoder
} catch (UnsupportedEncodingException e
logger
}
String[] arr = new String[
arr[
arr[
arr[
arr[
String url = MessageFormat
URL urlmy = null;
try {
urlmy = new URL(url);
HttpURLConnection con = (HttpURLConnection) urlmy
con
con
nnect();
BufferedReader br = new BufferedReader(new InputStreamReader(con
String s =
StringBuffer sb = new StringBuffer(
while ((s = br
sb
}
ret =
} catch (MalformedURLException e) {
logger
} catch (IOException e) {
logger
}
}
return ret;
}
大家可以通過測試頁面進行測試
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27069.html