예제 #1
0
 /** Start animating the map towards the given point. */
 public void animateTo(final double latitude, final double longitude) {
   final int x = mOsmv.getScrollX();
   final int y = mOsmv.getScrollY();
   final Point p = TileSystem.LatLongToPixelXY(latitude, longitude, mOsmv.getZoomLevel(), null);
   final int worldSize_2 = TileSystem.MapSize(mOsmv.getZoomLevel()) / 2;
   mOsmv
       .getScroller()
       .startScroll(
           x, y, p.x - worldSize_2 - x, p.y - worldSize_2 - y, ANIMATION_DURATION_DEFAULT);
   mOsmv.postInvalidate();
 }
예제 #2
0
 @Override
 public GeoPoint fromPixels(int x, int y) {
   Point center = mView.getController().getCenter();
   x = x + center.x - mView.getWidth() / 2;
   y = y + center.y - mView.getHeight() / 2;
   double[] coords = TileFactory.PixelToLatLng(new int[] {x, y}, mView.getZoomLevel());
   GeoPoint geoPoint = new GeoPoint(coords[0], coords[1]);
   return geoPoint;
 }
예제 #3
0
 @Override
 public Point toPixels(GeoPoint in, Point out) {
   double[] coords = new double[] {in.getLatitudeE6() / 1E6, in.getLongitudeE6() / 1E6};
   int[] pixels = TileFactory.LatLngToPixel(coords, mView.getZoomLevel());
   Point center = mView.getController().getCenter();
   out.x = pixels[0] - center.x + mView.getWidth() / 2;
   out.y = pixels[1] - center.y + mView.getHeight() / 2;
   return out;
 }