Skip to content

Commit f8e3c9a

Browse files
fix: missing MapEventCameraIdle, MapEventStartMoveCamera events on iOS (#428)
This PR fixes #422 issue. --------- Co-authored-by: Joscha Eckert <[email protected]>
1 parent 2f902a8 commit f8e3c9a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

maplibre_ios/ios/maplibre_ios/Sources/maplibre_ios/MapViewDelegate.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,26 @@ class MapLibreView: NSObject, FlutterPlatformView, MLNMapViewDelegate,
192192
true
193193
}
194194

195+
// MLNMapViewDelegate method called when camera is about to start changing
196+
func mapView(_: MLNMapView, regionWillChangeWith reason: MLNCameraChangeReason, animated _: Bool) {
197+
let changeReason: CameraChangeReason = switch reason {
198+
case .gestureOneFingerZoom, .gesturePan, .gesturePinch, .gestureRotate, .gestureTilt,
199+
.gestureZoomIn, .gestureZoomOut, .transitionCancelled:
200+
.apiGesture
201+
case .programmatic:
202+
.apiAnimation
203+
default:
204+
.developerAnimation
205+
}
206+
207+
_flutterApi.onStartMoveCamera(reason: changeReason) { _ in }
208+
}
209+
210+
/// MLNMapViewDelegate method called when camera has finished changing
211+
func mapView(_: MLNMapView, regionDidChangeWith _: MLNCameraChangeReason, animated _: Bool) {
212+
_flutterApi.onCameraIdle { (_: Result<Void, PigeonError>) in }
213+
}
214+
195215
// MLNMapViewDelegate method called when map has finished loading
196216
func mapView(_ mapView: MLNMapView, didFinishLoading _: MLNStyle) {
197217
// setCamera() can only be used after the map did finish loading

0 commit comments

Comments
 (0)