diff options
Diffstat (limited to 'androidApp')
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>© 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> |