【问题标题】:OSMDROID - Zoom to show all markersOSMDROID - 缩放以显示所有标记
【发布时间】:2021-08-03 23:20:33
【问题描述】:

这是 GitHub 上问题 #1339#156 的重复,但我找不到它们有帮助

我有一个应用程序,它在地图上显示两个点我已经实现标记设置正确,但是如何缩放地图,以便所有标记都可见?如果我只有一个标记,这很容易,因为我知道位置并设置固定缩放。

我尝试使用 BoundingBox,收集所有点的最大和最小纬度/经度值,但我遇到了这个错误:

Process: com.example.cslapp, PID: 9216
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.cslapp/com.example.cslapp.MapRoute}: java.lang.IllegalArgumentException: north must be in [-85.05112877980658,85.05112877980658]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3492)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3652)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2099)

我也尝试过使用

BoundingBox box = BoundingBox.fromGeoPoints(waypoints);
map.zoomToBoundingBox(box, true);

但这导致了同样的错误。

任何建议或解决方案都会很棒,谢谢!

【问题讨论】:

    标签: osmdroid


    【解决方案1】:

    这个问题已经持续数周了。奇怪的是:在某些片段中,我经常收到此错误,而在某些片段中则永远不会。有人说是因为布局还没有膨胀,但我不确定是否真的是这样。

    一个似乎有帮助的解决方法是在 Runnable 中运行缩放功能:

    mapView.post {
                mapView.zoomToBoundingBox(boundingBox, true, 100)
            }
    

    【讨论】:

      猜你喜欢
      • 2013-01-27
      • 1970-01-01
      • 2014-01-03
      • 2011-08-25
      • 2012-07-18
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      相关资源
      最近更新 更多