diff options
Diffstat (limited to 'androidApp')
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index f577613..cfb59a0 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -65,7 +65,7 @@ class MapFragment : GlobeMapFragment() { val tmpInfo = RemoteTileInfoNew(layer[0], layer[1].toInt(), layer[2].toInt()) tileInfo = tileInfoSetCacheDir(layer[0], tmpInfo) tileInfo?.let { - setZoomLimits(it.minZoom, it.maxZoom) + setZoomLimits(layer[1].toInt(), layer[2].toInt()) } } @@ -92,7 +92,7 @@ class MapFragment : GlobeMapFragment() { userMotion: Boolean ) { super.mapDidStopMoving(mapControl, corners, userMotion) - Log.d("MapFragment", "Height: ${mapControl?.height}") + Log.d("MapFragment", "Height: %7.7f".format(mapControl?.height)) } override fun userDidSelect( @@ -320,17 +320,22 @@ class MapFragment : GlobeMapFragment() { fun focusOn( latitude: Double, longitude: Double, - height: Double? = 0.00001, + height: Double = 0.00001, animated: Boolean = true ) { - val lat = latitude * Math.PI / 180 - val lon = longitude * Math.PI / 180 - // Ensure height is equal or higher than bottom limit - val z = mapControl.zoomLimitMin.coerceAtLeast(height ?: 0.0) - if (animated) { - mapControl.animatePositionGeo(lon, lat, z, 0.2) - } else { - mapControl.setPositionGeo(lon, lat, z) + mapControl?.addPostSurfaceRunnable { + val lat = latitude * Math.PI / 180 + val lon = longitude * Math.PI / 180 + // Ensure height is equal or higher than bottom limit + Log.d("MapFragment", "Target: %7.7f".format(height)) + Log.d("MapFragment", "Min: %7.7f".format(mapControl.zoomLimitMin)) + val z = height.coerceAtLeast(mapControl.zoomLimitMin) + Log.d("MapFragment", "Final: %7.7f".format(z)) + if (animated) { + mapControl.animatePositionGeo(lon, lat, z, 0.2) + } else { + mapControl.setPositionGeo(lon, lat, z) + } } } |