From 317d132e092ea9e1f8d5e1d30b9fad38e6c6200b Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sun, 16 Jan 2022 02:58:04 -0600 Subject: Moved layer definitions to map_layers.xml and adjusted zoom limits, and adjusted zoomLevelToScale(zoom) --- .../TrackerMap/android/map/MapFragment.kt | 29 ++++++++++++++-------- androidApp/src/main/res/values/map_layers.xml | 23 +++++++++++++++++ androidApp/src/main/res/values/strings.xml | 18 -------------- 3 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 androidApp/src/main/res/values/map_layers.xml (limited to 'androidApp/src/main') 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) { diff --git a/androidApp/src/main/res/values/map_layers.xml b/androidApp/src/main/res/values/map_layers.xml new file mode 100644 index 0000000..c0e83a5 --- /dev/null +++ b/androidApp/src/main/res/values/map_layers.xml @@ -0,0 +1,23 @@ + + + + + + + + + + https://a.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png + 0 + 21 + © OpenStreetMap France | © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors + + + + https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x} + 0 + 20 + Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community + + + \ No newline at end of file diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 67f0a26..a3d2f28 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -10,24 +10,6 @@ https://www.google.com/maps/place/%1$f,%2$f?z=19 - - - - - - - https://a.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png - 0 - 20 - © OpenStreetMap France | © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors - - - https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x} - 0 - 17 - Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community - - default Default -- cgit v1.2.3