Advertisement
flalli

getMapCorners

Dec 2nd, 2012
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.83 KB | None | 0 0
  1.     /**
  2.      *
  3.      * @return a Pair of two pairs with: top left corner (lat, lon), bottom right corner (lat, lon)
  4.      */
  5.     public Pair<Pair<Double, Double>, Pair<Double, Double>> getMapCorners() {
  6.         GeoPoint topLeft = this.getProjection().fromPixels(0, 0);
  7.         GeoPoint bottomRight = this.getProjection().fromPixels(getWidth(),getHeight());
  8.  
  9.         double topLeftLat = topLeft.getLatitudeE6() / 1.0E6;
  10.         double topLeftLon = topLeft.getLongitudeE6() / 1.0E6;
  11.  
  12.         double bottomRightLat = bottomRight.getLatitudeE6() / 1.0E6;
  13.         double bottomRightLon = bottomRight.getLongitudeE6() / 1.0E6;
  14.  
  15.         return new Pair<Pair<Double, Double>, Pair<Double, Double>>(
  16.                 new Pair<Double, Double>(topLeftLat, topLeftLon),
  17.                 new Pair<Double, Double>(bottomRightLat, bottomRightLon));
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement