I've made an app with an osmdroid mapview, the user is able to import a jpeg into the map as a groundoverlay, the image imported would be the floorplan of a building and would fill the mapview. Does anyone know how I would go about settings the scroll boundaries of the mapview to the edges of the groundoverlay so that the user cannot scroll outside of the groundoverlay/floorplan.
any ideas on this would be great
Set the viewable area with mapView.setScrollableAreaLimit(groundOverlayBoundingBox)
.
You may also need to limit the min zoom level (MapView#setMinZoomLevel
).
Now, how to compute the GroundOverlay
BoundingBox
?
GroundOverlay
has no bearing => look at GroundOverlay#draw
source code, at pEast
and pSouthEast
computation. This should be a good starting point. EDIT - with the maths:
GeoPoint pEast = position.destinationPoint(width, 90.0f);
GeoPoint pSouthEast = pEast.destinationPoint(height, -180.0f);
int north = position.getLatitudeE6()*2 - pSouthEast.getLatitudeE6();
int west = position.getLongitudeE6()*2 - pEast.getLongitudeE6();
BoundingBoxE6 bb = new BoundingBoxE6(north, pEast.getLongitudeE6(),
pSouthEast.getLatitudeE6(), west);
GeometryMath#getBoundingBoxForRotatatedRectangle
in osmdroid which could help. But the scroll will not fit perfectly with the ground overlay edges.