diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-16 02:58:04 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-16 02:58:04 -0600 |
commit | f8e7e755dc8e557e1e5b9e9be318f8415a2c7f8e (patch) | |
tree | 6481f867e561a32be4ad408c26932b255198bf8a /androidApp/src/main/java/mx | |
parent | d517d83094230c82c3cdb8c93e856fe56f22e0c2 (diff) | |
download | etbsa-trackermap-mobile-f8e7e755dc8e557e1e5b9e9be318f8415a2c7f8e.tar.gz etbsa-trackermap-mobile-f8e7e755dc8e557e1e5b9e9be318f8415a2c7f8e.tar.bz2 etbsa-trackermap-mobile-f8e7e755dc8e557e1e5b9e9be318f8415a2c7f8e.zip |
Moved layer definitions to map_layers.xml and adjusted zoom limits, and adjusted zoomLevelToScale(zoom)
Diffstat (limited to 'androidApp/src/main/java/mx')
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt | 29 |
1 files changed, 18 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 9fa37c9..e30885d 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 @@ -315,11 +315,16 @@ class MapFragment : GlobeMapFragment() { )) } - fun focusOn(latitude: Double, longitude: Double, height: Double = 0.00009, animated: Boolean = true) { + fun focusOn( + latitude: Double, + longitude: Double, + 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) + val z = mapControl.zoomLimitMin.coerceAtLeast(height ?: 0.0) if (animated) { mapControl.animatePositionGeo(lon, lat, z, 0.2) } else { @@ -340,16 +345,18 @@ class MapFragment : GlobeMapFragment() { } private fun setZoomLimits(minZoom: Int, maxZoom: Int) { - mapControl?.setZoomLimits( - mapControl.heightForMapScale( - MapCalculus.zoomLevelToScale(maxZoom) - ?: MapCalculus.zoomLevelToScale(20)!! - ), - mapControl.heightForMapScale( - MapCalculus.zoomLevelToScale(minZoom) - ?: MapCalculus.zoomLevelToScale(1)!! + mapControl?.let { + it.setZoomLimits( + it.heightForMapScale( + MapCalculus.zoomLevelToScale(maxZoom) + ?: MapCalculus.zoomLevelToScale(21)!! + ), + it.heightForMapScale( + MapCalculus.zoomLevelToScale(minZoom) + ?: MapCalculus.zoomLevelToScale(1)!! + ) ) - ) + } } fun updateTileInfo(url: String, tileInfo: TileInfoNew) { |