百度地图坐标与苹果自带地图经纬度之间的相互转换方法

  • 百度坐标转高德坐标
    + (CLLocationCoordinate2D)GCJ02FromBD09:(CLLocationCoordinate2D)coor{
    CLLocationDegrees x_pi =3.141592653589793243000.0/180.0;
    CLLocationDegrees x = coor.longitude -0.0065, y = coor.latitude -0.006;
    CLLocationDegrees z =sqrt(x * x + y * y) -0.00002
    sin(y * x_pi);
    CLLocationDegrees theta =atan2(y, x) -0.000003*cos(x * x_pi);
    CLLocationDegrees gg_lon = z *cos(theta);
    CLLocationDegrees gg_lat = z *sin(theta);
    returnCLLocationCoordinate2DMake(gg_lat, gg_lon);
    }
  • 高德坐标转百度坐标
    + (CLLocationCoordinate2D)BD09FromGCJ02: (CLLocationCoordinate2D)coor{
    CLLocationDegrees x_pi =3.141592653589793243000.0/180.0;
    CLLocationDegrees x = coor.longitude, y = coor.latitude;
    CLLocationDegrees z =sqrt(x * x + y * y) +0.00002
    sin(y * x_pi);
    CLLocationDegrees theta =atan2(y, x) +0.000003*cos(x * x_pi);
    CLLocationDegrees bd_lon = z *cos(theta) +0.0065;
    CLLocationDegrees bd_lat = z *sin(theta) +0.006;
    return CLLocationCoordinate2DMake(bd_lat, bd_lon);
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容