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 | |
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)
4 files changed, 44 insertions, 31 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) { 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- Tile URLs --> + <!-- [0] = tile server URL --> + <!-- [1] = min zoom --> + <!-- [2] = max zoom --> + <!-- [3] = attribution text --> + + <string-array name="maps_streets_tile_url" translatable="false"> + <item>https://a.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png</item> + <item>0</item> + <item>21</item> + <item>© OpenStreetMap France | © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors</item> + </string-array> + + <string-array name="maps_satellite_tile_url" translatable="false"> + <item>https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}</item> + <item>0</item> + <item>20</item> + <item>Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community</item> + </string-array> + +</resources>
\ 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 </string> - <!-- Tile URLs --> - <!-- [0] = tile server URL --> - <!-- [1] = min zoom --> - <!-- [2] = max zoom --> - <!-- [3] = attribution text --> - <string-array name="maps_streets_tile_url" translatable="false"> - <item>https://a.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png</item> - <item>0</item> - <item>20</item> - <item>© OpenStreetMap France | © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors</item> - </string-array> - <string-array name="maps_satellite_tile_url" translatable="false"> - <item>https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}</item> - <item>0</item> - <item>17</item> - <item>Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community</item> - </string-array> - <string name="notification_channel_id" translatable="false">default</string> <string name="notification_channel" translatable="false">Default</string> 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 d4c5261..118c117 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt @@ -28,8 +28,9 @@ class MapCalculus { 16 -> 8530.9183354 17 -> 4265.4591677 18 -> 2132.72958385 - 19 -> 1000.0 // made up - 20 -> 500.0 // made up + 19 -> 1066.36479193 + 20 -> 533.182395965 + 21 -> 266.5911979825 else -> null } } |