コード例 #1
0
  /**
   * Get the longitude distance in the middle latitude
   *
   * @param minLongitude
   * @param maxLongitude
   * @return
   */
  public static double getLongitudeDistance(double minLongitude, double maxLongitude) {
    LatLng leftMiddle = new LatLng(0, minLongitude);
    LatLng middle = new LatLng(0, maxLongitude - minLongitude);
    LatLng rightMiddle = new LatLng(0, maxLongitude);

    List<LatLng> path = new ArrayList<LatLng>();
    path.add(leftMiddle);
    path.add(middle);
    path.add(rightMiddle);

    double lonDistance = SphericalUtil.computeLength(path);
    return lonDistance;
  }
コード例 #2
0
 private void showDistance() {
   double distance =
       SphericalUtil.computeDistanceBetween(mMarkerA.getPosition(), mMarkerB.getPosition());
   mTextView.setText("The markers are " + formatNumber(distance) + " apart.");
 }
コード例 #3
0
 /**
  * Get the latitude distance in the middle longitude
  *
  * @param minLatitude
  * @param maxLatitude
  * @return
  */
 public static double getLatitudeDistance(double minLatitude, double maxLatitude) {
   LatLng lowerMiddle = new LatLng(minLatitude, 0);
   LatLng upperMiddle = new LatLng(maxLatitude, 0);
   double latDistance = SphericalUtil.computeDistanceBetween(lowerMiddle, upperMiddle);
   return latDistance;
 }