/** * 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; }
private void showDistance() { double distance = SphericalUtil.computeDistanceBetween(mMarkerA.getPosition(), mMarkerB.getPosition()); mTextView.setText("The markers are " + formatNumber(distance) + " apart."); }
/** * 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; }