本文分别通过百度地图API和高德地图API,通过WGS84的坐标返回详细的地理位置。
一、通过百度地图API进行反坐标逆向地理位置.
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;
private JsonNode getAddressBaidu(double lng, double lat) {
String location = lat + "," + lng;
if (lat == 1.0E-6 || lat == 0) {
return null;
}
String key="你的key";
BufferedReader in = null;
URL tirc = null;
try {
tirc = new URL("http://api.map.baidu.com/reverse_geocoding/v3/?ak="+key+"=" + location + "&&output=json&coordtype=wgs84ll");
} catch (MalformedURLException e1) {
log.error("反查坐标时出错" + location);