File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public struct MapView<T: MapViewHostViewController>: UIViewControllerRepresentab
33
33
var gestures = [ MapGesture] ( )
34
34
35
35
var onStyleLoaded : ( ( MLNStyle ) -> Void ) ?
36
+ var onUserTrackingModeChanged : ( ( MLNUserTrackingMode , Bool ) -> Void ) ?
36
37
var onViewProxyChanged : ( ( MapViewProxy ) -> Void ) ?
37
38
var proxyUpdateMode : ProxyUpdateMode ?
38
39
@@ -105,6 +106,9 @@ public struct MapView<T: MapViewHostViewController>: UIViewControllerRepresentab
105
106
// Link the style loaded to the coordinator that emits the delegate event.
106
107
context. coordinator. onStyleLoaded = onStyleLoaded
107
108
109
+ // Link the user tracking change to the coordinator that emits the delegate event.
110
+ context. coordinator. onUserTrackingModeChange = onUserTrackingModeChanged
111
+
108
112
// Add all gesture recognizers
109
113
for gesture in gestures {
110
114
registerGesture ( controller. mapView, context, gesture: gesture)
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ MLNMapViewDelegate {
44
44
var cameraUpdateContinuation : CheckedContinuation < Void , Never > ?
45
45
46
46
var onStyleLoaded : ( ( MLNStyle ) -> Void ) ?
47
+ var onUserTrackingModeChange : ( ( MLNUserTrackingMode , Bool ) -> Void ) ?
47
48
var onGesture : ( MLNMapView , UIGestureRecognizer ) -> Void
48
49
var onViewProxyChanged : ( MapViewProxy ) -> Void
49
50
var proxyUpdateMode : ProxyUpdateMode
@@ -438,6 +439,10 @@ MLNMapViewDelegate {
438
439
}
439
440
}
440
441
442
+ public func mapView( _: MLNMapView , didChange mode: MLNUserTrackingMode , animated: Bool ) {
443
+ onUserTrackingModeChange ? ( mode, animated)
444
+ }
445
+
441
446
// MARK: MapViewProxy
442
447
443
448
@MainActor private func updateViewProxy( mapView: MLNMapView , reason: MLNCameraChangeReason ) {
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ public extension MapView {
14
14
return newMapView
15
15
}
16
16
17
+ func onUserTrackingModeChanged( _ perform: @escaping ( MLNUserTrackingMode , Bool ) -> Void ) -> MapView {
18
+ var newMapView = self
19
+ newMapView. onUserTrackingModeChanged = perform
20
+ return newMapView
21
+ }
22
+
17
23
/// Allows you to set properties of the underlying MLNMapView directly
18
24
/// in cases where these have not been ported to DSL yet.
19
25
/// Use this function to modify various properties of the MLNMapView instance.
You can’t perform that action at this time.
0 commit comments