1、高德经纬度转百度经纬度:
"http://api.map.baidu.com/geoconv/v1/?coords="+endlo+","+endla+"&from=3&to=5&ak="+"Hi7RspVbu9xQNVUi0S7iP0OLLQbNfn"+"&mcode=07:63:0A:B5:14:92:C6:95:43:8C:5E:78:1D:27:27:D5:2D:7E:81:64;com.tianxin.mapclient.liteapp";
百度链接返回结果:
{"status":0,"result":[{"x":113.82272467469467,"y":23.041698608356179}]}
参数说明:
其他参数固定不变。只需填写经纬度,百度AK,百度安全码,四个参数
endlo 是纬度——23.025845
endla 是经度——113.752532
AK与mcode 是百度应用AK和百度安全码——
2、百度经纬度转高德经纬度
public static double[] baidu2AMap(double lat, double lon) {try {if (lat != 0 && lon != 0) {double var4 = 0.006401062D;double var6 = 0.0060424805D;double[] var2 = null;for (int var3 = 0; var3 < 2; ++var3) {var2 = new double[2];double var16 = lon - var4;double var18 = lat - var6;double[] var29 = new double[2];double var24 = Math.cos(b(var16) + Math.atan2(var18, var16)) * (a(var18) + Math.sqrt(var16 * var16 + var18 * var18)) + 0.0065D;double var26 = Math.sin(b(var16) + Math.atan2(var18, var16)) * (a(var18) + Math.sqrt(var16 * var16 + var18 * var18)) + 0.006D;var29[1] = (c(var24));var29[0] = (c(var26));var2[1] = (c(lon + var16 - var29[1]));var2[0] = (c(lat + var18 - var29[0]));var4 = lon - var2[1];var6 = lat - var2[0];}return var2;}} catch (Throwable var28) {// ll.a(var28, "OffsetUtil", "B2G");}return new double[]{lat, lon}; }private static double a = 3.141592653589793D;private static double a(double var0) {return Math.sin(var0 * 3000.0D * (a / 180.0D)) * 2.0E-5D; }private static double b(double var0) {return Math.cos(var0 * 3000.0D * (a / 180.0D)) * 3.0E-6D; }private static double c(double var0) {return (new BigDecimal(var0)).setScale(8, 4).doubleValue(); }
测试数据
private double [] baidu2amap;
baidu2amap = baidu2AMap(23.029103,113.760184);
baidu2amap纬度===23.02278288 baidu2amap进度===113.75376479