Live scroll portrait (in pixels, but not long)

I need to scroll MapView programmatically to make sure something is in sight. I know how many pixels he needs to scroll in each direction. I see methods (in MapController) to animate it in a specific GeoPoint and scroll it with pixels without animation. But do nothing pixel by pixel with animation.

What is an easy way to do this?

+3
source share
1 answer

Well, since no one answered, I will answer myself. This works fine:

public static void panMap (int x, int y, MapView map) {
    Point ptPixels = new Point();
    GeoPoint geoPt = map.getMapCenter();
    Projection projection = map.getProjection();
    projection.toPixels(geoPt, ptPixels);
    ptPixels.x += x;
    ptPixels.y += y;
    geoPt = projection.fromPixels(ptPixels.x, ptPixels.y);
    map.getController().animateTo(geoPt);
}
+9
source

Source: https://habr.com/ru/post/1775368/


All Articles