File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ extension MapViewCoordinator: MLNMapViewDelegate {
260260 // FIXME: CI complains about MainActor.assumeIsolated being unavailable before iOS 17, despite building on iOS 17.2... This is an epic hack to fix it for now. I can only assume this is an issue with Xcode pre-15.3
261261 // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce.
262262 Task { @MainActor in
263- updateViewPort ( mapView: mapView)
263+ updateViewPort ( mapView: mapView, reason : reason )
264264 }
265265
266266 guard !suppressCameraUpdatePropagation else {
@@ -275,12 +275,13 @@ extension MapViewCoordinator: MLNMapViewDelegate {
275275
276276 // MARK: MapViewPort
277277
278- @MainActor private func updateViewPort( mapView: MLNMapView ) {
278+ @MainActor private func updateViewPort( mapView: MLNMapView , reason : MLNCameraChangeReason ) {
279279 // Calculate the Raw "ViewPort"
280280 let calculatedViewPort = MapViewPort (
281281 center: mapView. centerCoordinate,
282282 zoom: mapView. zoomLevel,
283- direction: mapView. direction
283+ direction: mapView. direction,
284+ lastReasonForChange: CameraChangeReason ( reason)
284285 )
285286
286287 onViewPortChanged ( calculatedViewPort)
Original file line number Diff line number Diff line change @@ -16,16 +16,25 @@ public struct MapViewPort: Hashable, Equatable {
1616 /// The current compass direction of the MapView
1717 public let direction : CLLocationDirection
1818
19- public init ( center: CLLocationCoordinate2D , zoom: Double , direction: CLLocationDirection ) {
19+ /// The reason the view port was changed.
20+ public let lastReasonForChange : CameraChangeReason ?
21+
22+ public init ( center: CLLocationCoordinate2D ,
23+ zoom: Double ,
24+ direction: CLLocationDirection ,
25+ lastReasonForChange: CameraChangeReason ? )
26+ {
2027 self . center = center
2128 self . zoom = zoom
2229 self . direction = direction
30+ self . lastReasonForChange = lastReasonForChange
2331 }
2432
2533 public static func zero( zoom: Double = 10 ) -> MapViewPort {
2634 MapViewPort ( center: CLLocationCoordinate2D ( latitude: 0 , longitude: 0 ) ,
2735 zoom: zoom,
28- direction: 0 )
36+ direction: 0 ,
37+ lastReasonForChange: nil )
2938 }
3039}
3140
You can’t perform that action at this time.
0 commit comments