fix(map): `generateBoxOverlay` event listener

pull/1292/head
andrekir 2024-10-05 09:30:40 -03:00
rodzic ed1ce77608
commit 625bc6837b
1 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -549,6 +549,17 @@ fun MapView(
cacheEstimate = context.getString(R.string.map_cache_tiles, tileCount) cacheEstimate = context.getString(R.string.map_cache_tiles, tileCount)
} }
val boxOverlayListener = object : MapListener {
override fun onScroll(event: ScrollEvent): Boolean {
map.generateBoxOverlay()
return true
}
override fun onZoom(event: ZoomEvent): Boolean {
return false
}
}
fun startDownload() { fun startDownload() {
val boundingBox = downloadRegionBoundingBox ?: return val boundingBox = downloadRegionBoundingBox ?: return
try { try {
@ -614,6 +625,7 @@ fun MapView(
0 -> showCurrentCacheInfo = true 0 -> showCurrentCacheInfo = true
1 -> { 1 -> {
map.generateBoxOverlay() map.generateBoxOverlay()
map.addMapListener(boxOverlayListener)
dialog.dismiss() dialog.dismiss()
} }
@ -656,7 +668,7 @@ fun MapView(
// Disables default +/- button for zooming // Disables default +/- button for zooming
zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER) zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
addMapEventListener { addMapEventListener {
model.updateMapCenterAndZoom(map.projection.currentCenter, map.zoomLevelDouble) model.updateMapCenterAndZoom(projection.currentCenter, zoomLevelDouble)
} }
zoomToNodes() zoomToNodes()
} }
@ -668,6 +680,7 @@ fun MapView(
cacheEstimate = cacheEstimate, cacheEstimate = cacheEstimate,
onExecuteJob = { startDownload() }, onExecuteJob = { startDownload() },
onCancelDownload = { onCancelDownload = {
map.removeMapListener(boxOverlayListener)
downloadRegionBoundingBox = null downloadRegionBoundingBox = null
map.overlays.removeAll { it is Polygon } map.overlays.removeAll { it is Polygon }
map.invalidate() map.invalidate()