aboutsummaryrefslogtreecommitdiff
path: root/androidApp
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 02:58:04 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 02:58:04 -0600
commit317d132e092ea9e1f8d5e1d30b9fad38e6c6200b (patch)
tree6481f867e561a32be4ad408c26932b255198bf8a /androidApp
parent5d018cdfc1af8d356716dd45d81eb64dbed6b3e4 (diff)
downloadetbsa-trackermap-mobile-317d132e092ea9e1f8d5e1d30b9fad38e6c6200b.tar.gz
etbsa-trackermap-mobile-317d132e092ea9e1f8d5e1d30b9fad38e6c6200b.tar.bz2
etbsa-trackermap-mobile-317d132e092ea9e1f8d5e1d30b9fad38e6c6200b.zip
Moved layer definitions to map_layers.xml and adjusted zoom limits, and adjusted zoomLevelToScale(zoom)
Diffstat (limited to 'androidApp')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt29
-rw-r--r--androidApp/src/main/res/values/map_layers.xml23
-rw-r--r--androidApp/src/main/res/values/strings.xml18
3 files changed, 41 insertions, 29 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>&#169; OpenStreetMap France | &#169; &lt;a href="https://www.openstreetmap.org/copyright"&gt;OpenStreetMap&lt;/a&gt; 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 &#169; Esri &#8212; 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>&#169; OpenStreetMap France | &#169; &lt;a href="https://www.openstreetmap.org/copyright"&gt;OpenStreetMap&lt;/a&gt; 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 &#169; Esri &#8212; 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>