osmdroid将设置边界设置为mapview中图像叠加的边缘

时间:2014-07-28 11:59:38

标签: android android-mapview osmdroid bounding-box overlays

我使用osmdroid mapview创建了一个应用程序,用户可以将jpeg导入地图作为地面覆盖,导入的图像将是建筑物的平面图并填充mapview。有谁知道如何将mapview的滚动边界设置到地面覆盖的边缘,这样用户就无法在地面覆盖/平面图之外滚动。

对此有任何想法都很棒< / p>

1 个答案:

答案 0 :(得分:2)

使用mapView.setScrollableAreaLimit(groundOverlayBoundingBox)设置可查看区域。

您可能还需要限制最小缩放级别(MapView#setMinZoomLevel)。

现在,如何计算GroundOverlay BoundingBox

  • 如果您的GroundOverlay没有承受=>查看GroundOverlay#draw源代码,pEastpSouthEast计算。这应该是一个很好的起点。

编辑 - 数学:

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);
  • 如果它有一个方位,......很棘手。 osmdroid中有一个GeometryMath#getBoundingBoxForRotatatedRectangle可以提供帮助。但滚动条与地面覆盖边缘不完全吻合。