diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-16 14:09:38 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-16 14:09:38 -0600 |
commit | cefdbf2e352f52f2b07b138ed9ab722e2089578a (patch) | |
tree | 0a85cfc217cf7d11c66001446d3897cd8cf5204b /androidApp/src/main | |
parent | b5fc29667e85cc504e09cd9975590f6906d2ad8e (diff) | |
download | etbsa-trackermap-mobile-cefdbf2e352f52f2b07b138ed9ab722e2089578a.tar.gz etbsa-trackermap-mobile-cefdbf2e352f52f2b07b138ed9ab722e2089578a.tar.bz2 etbsa-trackermap-mobile-cefdbf2e352f52f2b07b138ed9ab722e2089578a.zip |
Fixed focusOn not respecting max zoom, and added zoom level 21 to MapCalculus
Diffstat (limited to 'androidApp/src/main')
-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) + } } } |