解决Android使用百度定位坐标显示到地图上偏移过大问题

来源:互联网 发布:淘宝网商品分类 编辑:程序博客网 时间:2024/04/30 14:47

解决方案来源

http://www.oschina.net/code/snippet_260395_39205

原文是PHP和js的代码

采用java代码解决办法如下

private LatLng pianyi(double lon,double lat){  double x = lon; double y = lat;          double z = Math.sqrt(x*x+y*y) + 0.00002 *Math.sin(y*Math.PI) ;          double temp =Math.atan2(y, x)  + 0.000003 * Math.cos(x*Math.PI);         double bdLon = z * Math.cos(temp) + 0.0065;          double bdLat = z * Math.sin(temp) + 0.006;         LatLng newcenpt = new LatLng(bdLat, bdLon);        return newcenpt;}


0 0