kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
refactor(map): set fixed `maxZoomLevel` (20.0)
rodzic
625bc6837b
commit
be6ea79c04
|
@ -262,6 +262,8 @@ private fun MapView.addMapEventListener(onEvent: () -> Unit) {
|
||||||
}, INACTIVITY_DELAY_MILLIS))
|
}, INACTIVITY_DELAY_MILLIS))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val MaxZoomLevel = 20.0
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MapView(
|
fun MapView(
|
||||||
model: UIViewModel = viewModel(),
|
model: UIViewModel = viewModel(),
|
||||||
|
@ -519,7 +521,7 @@ fun MapView(
|
||||||
val id = mPrefs.getInt(mapStyleId, 0)
|
val id = mPrefs.getInt(mapStyleId, 0)
|
||||||
debug("mapStyleId from prefs: $id")
|
debug("mapStyleId from prefs: $id")
|
||||||
return CustomTileSource.getTileSource(id).also {
|
return CustomTileSource.getTileSource(id).also {
|
||||||
map.maxZoomLevel = it.maximumZoomLevel.toDouble()
|
zoomLevelMax = it.maximumZoomLevel.toDouble()
|
||||||
showDownloadButton =
|
showDownloadButton =
|
||||||
if (it is OnlineTileSourceBase) it.tileSourcePolicy.acceptsBulkDownload() else false
|
if (it is OnlineTileSourceBase) it.tileSourcePolicy.acceptsBulkDownload() else false
|
||||||
}
|
}
|
||||||
|
@ -531,8 +533,7 @@ fun MapView(
|
||||||
fun MapView.generateBoxOverlay() {
|
fun MapView.generateBoxOverlay() {
|
||||||
overlays.removeAll { it is Polygon }
|
overlays.removeAll { it is Polygon }
|
||||||
val zoomFactor = 1.3 // zoom difference between view and download area polygon
|
val zoomFactor = 1.3 // zoom difference between view and download area polygon
|
||||||
zoomLevelMax = maxZoomLevel
|
zoomLevelMin = minOf(zoomLevelDouble, zoomLevelMax)
|
||||||
zoomLevelMin = maxOf(zoomLevelDouble, maxZoomLevel)
|
|
||||||
downloadRegionBoundingBox = boundingBox.zoomIn(zoomFactor)
|
downloadRegionBoundingBox = boundingBox.zoomIn(zoomFactor)
|
||||||
val polygon = Polygon().apply {
|
val polygon = Polygon().apply {
|
||||||
points = Polygon.pointsAsRect(downloadRegionBoundingBox).map {
|
points = Polygon.pointsAsRect(downloadRegionBoundingBox).map {
|
||||||
|
@ -665,6 +666,7 @@ fun MapView(
|
||||||
isTilesScaledToDpi = true
|
isTilesScaledToDpi = true
|
||||||
// sets the minimum zoom level (the furthest out you can zoom)
|
// sets the minimum zoom level (the furthest out you can zoom)
|
||||||
minZoomLevel = 1.5
|
minZoomLevel = 1.5
|
||||||
|
maxZoomLevel = MaxZoomLevel
|
||||||
// Disables default +/- button for zooming
|
// Disables default +/- button for zooming
|
||||||
zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
|
zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
|
||||||
addMapEventListener {
|
addMapEventListener {
|
||||||
|
|
Ładowanie…
Reference in New Issue