Issue
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
Solution
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
?
- If your
GroundOverlay
has no bearing => look atGroundOverlay#draw
source code, atpEast
andpSouthEast
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);
- If it has a bearing, ... tricky. There is a
GeometryMath#getBoundingBoxForRotatatedRectangle
in osmdroid which could help. But the scroll will not fit perfectly with the ground overlay edges.
Answered By - MKer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.