1、用于地区名称不规范的情况,需要百度的逆地理编码api
2、保留经纬度小数点后六位:
Double dLng=Double.parseDouble(lng);
Double dlat=Double.parseDouble(lat);
DecimalFormat df=new DecimalFormat("0.000000");
String flng=df.format(dLng);
String flat=df.format(dlat);
3、调用api会org.apache.http.conn.HttpHostConnectException timeout
解决:
HttpGet get = new HttpGet(uri);
RequestConfig config=RequestConfig.custom()
.setConnectionRequestTimeout(10000)
.setSocketTimeout(10000)
.setConnectTimeout(20000)
.build();
get.setConfig(config);
4、去除字符串前后空格
String str=" 字符串 ";
str.trim();