zoukankan      html  css  js  c++  java
  • 百度地图坐标转换

    在百度地图开发过程中,有可能会遇到一些关于坐标转换的问题,下面就把自己在项目过程中遇到的一些转换方法以及网上搜集到的一些方法写下来,以备不时之需

    1.国测局坐标转百度坐标

    /**  
         * 国测局转换百度经纬度  
         * @param point  
         * @return  
         */  
        public static LatLng gcjTobaidu(LatLng point) {  
            // double x = gg_lon, y = gg_lat;  
            double x = point.longitude, y = point.latitude;  
            double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);  
            double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);  
            double bd_lon = z * Math.cos(theta) + 0.0065;  
            double bd_lat = z * Math.sin(theta) + 0.006;  
            LatLng point1 = new LatLng(bd_lat,bd_lon);  
            return point1;  
        }  

    2.接下来是百度地图开发文档上面的坐标转换方法

      这里用到com.baidu.mapapi.map包下面的Projection类,我们要实现坐标转换首先要获取到百度地图的Projection

      方法:

    Projection mProjection=mapView.getMap().getProjection()

    然后用mProjection去调用百度api里面已经封装好的坐标转换方法
      

    1. 屏幕坐标  转  屏幕坐标  

        返回值        方法
        LatLng        fromScreenLocation(Point point)

      2. 屏幕坐标  转  地理坐标  

        该方法把以米为计量单位的距离(沿赤道)在当前缩放水平下转换到一个以像素(水平)为计量单位的距离。

        返回值        方法
        float          metersToEquatorPixels(float meters)

      3. 地理坐标  转  openGL坐标

        在 OnMapDrawFrameCallback 的 onMapDrawFrame 函数中使用。  

        返回值        方法
        PointF        toOpenGLLocation(LatLng location, MapStatus mapStatus)

      
      

      4. 地理坐标   转  屏幕坐标  

        返回值        方法
        Point        toScreenLocation(LatLng location)

  • 相关阅读:
    线程
    开启程序子进程的方式
    multiprocess模块
    计算机网络小知识
    解决粘包问题
    网络编程相关
    反射与元类
    多态相关
    封装相关与接口
    类的继承和组合
  • 原文地址:https://www.cnblogs.com/David-Young/p/4451423.html
Copyright © 2011-2022 走看看