aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 14:09:38 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 14:09:38 -0600
commit41aad20b7ebe24f318476c7f3fdb6be744dd5b9d (patch)
tree0a85cfc217cf7d11c66001446d3897cd8cf5204b /androidApp/src/main
parentfc4bbb4e4c0e1435b6d4599c79816575dcc8d01d (diff)
downloadetbsa-trackermap-mobile-41aad20b7ebe24f318476c7f3fdb6be744dd5b9d.tar.gz
etbsa-trackermap-mobile-41aad20b7ebe24f318476c7f3fdb6be744dd5b9d.tar.bz2
etbsa-trackermap-mobile-41aad20b7ebe24f318476c7f3fdb6be744dd5b9d.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.kt27
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)
+ }
}
}