Skip to content

Commit 74ff40c

Browse files
authored
Исправление региона карты (#368)
* Правки обновления региона при открытии приложения При запуске приложения устанавливаем регион для сохраненного города в фильтрах площадок * При создании карты настраиваем регион
1 parent 6833117 commit 74ff40c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

SwiftUI-WorkoutApp/Libraries/ClusteringMapView/Sources/ClusteringMapView/Public/ClusteringMapView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public struct ClusteringMapView: UIViewRepresentable {
4949
let view = MKMapView()
5050
view.delegate = context.coordinator
5151
view.cameraZoomRange = cameraZoomRange
52+
if LocationCoordinate(region).isSpecified {
53+
view.setRegion(region, animated: false)
54+
}
5255
addTrackingButtonIfNeeded(to: view)
5356
return view
5457
}

SwiftUI-WorkoutApp/Screens/Parks/Map/ParksMapScreen+ViewModel.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ extension ParksMapScreen {
9292
)
9393
logger.debug("Обновили cityId в кеше геокодирования на \(cityId)")
9494
}
95+
updateSelectedCity(selectedCity)
9596
}
9697

9798
/// Обновляет выбранный город для фильтра площадок
@@ -259,11 +260,13 @@ private extension ParksMapScreen.ViewModel {
259260
}
260261
return
261262
}
262-
region = .init(
263-
center: userCoordinate.coordinate,
264-
span: defaultCoordinateSpan
265-
)
266-
logger.debug("Регион карты сброшен на координаты: \(userCoordinate.lat), \(userCoordinate.lon)")
263+
if LocationCoordinate(region.center) != userCoordinate {
264+
region = .init(
265+
center: userCoordinate.coordinate,
266+
span: defaultCoordinateSpan
267+
)
268+
logger.debug("Регион карты сброшен на координаты: \(userCoordinate.lat), \(userCoordinate.lon)")
269+
}
267270
ignoreUserLocation = false
268271
}
269272
}

0 commit comments

Comments
 (0)