【问题标题】:osmdroid set bounds to edges of an image overlay in a mapviewosmdroid 在地图视图中设置图像覆盖边缘的边界
【发布时间】:2014-09-19 14:42:56
【问题描述】:

我制作了一个带有 osmdroid 地图视图的应用程序,用户可以将 jpeg 作为地面覆盖图导入地图,导入的图像将是建筑物的平面图并会填满地图视图。有谁知道我将如何将地图视图的滚动边界设置为地面覆盖的边缘,以便用户无法滚动到地面覆盖/平面图之外。

任何关于此的想法都会很棒

【问题讨论】:

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


    【解决方案1】:

    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 可以提供帮助。但卷轴不能与地面覆盖边缘完美契合。

    【讨论】:

    • 我将 groundoverlay 放置在特定的地理点,我还调整了导入的 jpeg 的大小以完全适合地图视图
    • 我喜欢这个主意,我只是无法获取 grouboverlay 区域的信息
    • 我将它直接集成到 GroundOverlay 类中,作为“getBoundingBox”方法。源代码已经提交。它将在 lib 的下一个版本中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 2021-03-03
    • 1970-01-01
    相关资源
    最近更新 更多