aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt27
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt1
2 files changed, 17 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)
+ }
}
}
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt
index 118c117..b1a6444 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt
@@ -31,6 +31,7 @@ class MapCalculus {
19 -> 1066.36479193
20 -> 533.182395965
21 -> 266.5911979825
+ 22 -> 133.29559899125
else -> null
}
}