From 41aad20b7ebe24f318476c7f3fdb6be744dd5b9d Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sun, 16 Jan 2022 14:09:38 -0600 Subject: Fixed focusOn not respecting max zoom, and added zoom level 21 to MapCalculus --- .../TrackerMap/android/map/MapFragment.kt | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android/map') 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) + } } } -- cgit v1.2.3