纬度和经度增量米

use*_*504 2 java android google-maps

我正在使用 Google 地图 v2 开发 Android 应用程序。在我的例子中,我有几个具有相同 LA/LO 的点,这会产生一些用户体验问题,其中一个是在地图上选择该点...所以我需要获得具有相同 LA/LO 的点,并为每个点添加一些米,例如50m有一个良好的距离,可以避免出现问题。我怎样才能在 LA/LO 上进行此计算以增加米数?

非常感谢!

小智 5

这是一个方法,它获取坐标、以米为单位的距离和以度为单位的方位角并返回新坐标。

public static Coordinate calcEndPoint(Coordinate center , int distance, double  bearing)
  {
      Coordinate gp=null;

      double R = 6371000; // meters , earth Radius approx
      double PI = 3.1415926535;
      double RADIANS = PI/180;
      double DEGREES = 180/PI;

      double lat2;
      double lon2;

      double lat1 = center.getDoubleLat() * RADIANS;
      double lon1 = center.getDoubleLon() * RADIANS;
      double radbear = bearing * RADIANS;

     // System.out.println("lat1="+lat1 + ",lon1="+lon1);

      lat2 = Math.asin( Math.sin(lat1)*Math.cos(distance / R) +
              Math.cos(lat1)*Math.sin(distance/R)*Math.cos(radbear) );
      lon2 = lon1 + Math.atan2(Math.sin(radbear)*Math.sin(distance / R)*Math.cos(lat1),
                     Math.cos(distance/R)-Math.sin(lat1)*Math.sin(lat2));

     // System.out.println("lat2="+lat2*DEGREES + ",lon2="+lon2*DEGREES);

      gp = new Coordinate( lon2*DEGREES, lat2*DEGREES);

      return(gp);
  }
Run Code Online (Sandbox Code Playgroud)