我使用osmdroid mapview创建了一个应用程序,用户可以将jpeg导入地图作为地面覆盖,导入的图像将是建筑物的平面图并填充mapview。有谁知道如何将mapview的滚动边界设置到地面覆盖的边缘,这样用户就无法在地面覆盖/平面图之外滚动。
对此有任何想法都很棒< / p>
答案 0 :(得分:2)
使用mapView.setScrollableAreaLimit(groundOverlayBoundingBox)
设置可查看区域。
您可能还需要限制最小缩放级别(MapView#setMinZoomLevel
)。
现在,如何计算GroundOverlay
BoundingBox
?
GroundOverlay
没有承受=>查看GroundOverlay#draw
源代码,pEast
和pSouthEast
计算。这应该是一个很好的起点。 编辑 - 数学:
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
可以提供帮助。但滚动条与地面覆盖边缘不完全吻合。