From deb30aafe68f3c7db61b718602627a92b9cebe79 Mon Sep 17 00:00:00 2001 From: Roman Laitarenko Date: Tue, 11 Nov 2025 13:30:02 +0200 Subject: [PATCH 1/3] fix annotation interactions stop working after annotation update --- .../CircleAnnotationController.swift | 73 ++++++++++--------- .../PointAnnotationController.swift | 73 ++++++++++--------- .../PolygonAnnotationController.swift | 73 ++++++++++--------- .../PolylineAnnotationController.swift | 73 ++++++++++--------- 4 files changed, 156 insertions(+), 136 deletions(-) diff --git a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/CircleAnnotationController.swift b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/CircleAnnotationController.swift index 6c9094e1..c00d2934 100644 --- a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/CircleAnnotationController.swift +++ b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/CircleAnnotationController.swift @@ -23,39 +23,7 @@ final class CircleAnnotationController: BaseAnnotationMessenger) -> Void) { do { - let updatedAnnotation = annotation.toCircleAnnotation() + var updatedAnnotation = annotation.toCircleAnnotation() + updatedAnnotation.configureHandlers(controller: self, managerId: managerId) try update(annotation: updatedAnnotation, managerId: managerId) completion(.success(())) } catch { @@ -427,5 +396,41 @@ extension MapboxMaps.CircleAnnotation { ) } } + +extension MapboxMaps.CircleAnnotation { + mutating func configureHandlers(controller: CircleAnnotationController, managerId: String) { + var configured = self + tapHandler = { [weak controller] _ in + let context = CircleAnnotationInteractionContext( + annotation: configured.toFLTCircleAnnotation(), + gestureState: .ended) + return controller?.tap(context, managerId: managerId) ?? false + } + longPressHandler = { [weak controller] _ in + let context = CircleAnnotationInteractionContext( + annotation: configured.toFLTCircleAnnotation(), + gestureState: .ended) + return controller?.longPress(context, managerId: managerId) ?? false + } + dragBeginHandler = { [weak controller] (annotation, _) in + let context = CircleAnnotationInteractionContext( + annotation: annotation.toFLTCircleAnnotation(), + gestureState: .started) + return controller?.drag(context, managerId: managerId) ?? false + } + dragChangeHandler = { [weak controller] (annotation, _) in + let context = CircleAnnotationInteractionContext( + annotation: annotation.toFLTCircleAnnotation(), + gestureState: .changed) + controller?.drag(context, managerId: managerId) + } + dragEndHandler = { [weak controller] (annotation, _) in + let context = CircleAnnotationInteractionContext( + annotation: annotation.toFLTCircleAnnotation(), + gestureState: .ended) + controller?.drag(context, managerId: managerId) + } + } +} // End of generated file. // swiftlint:enable file_length diff --git a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PointAnnotationController.swift b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PointAnnotationController.swift index cb0bbcab..817c7313 100644 --- a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PointAnnotationController.swift +++ b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PointAnnotationController.swift @@ -23,39 +23,7 @@ final class PointAnnotationController: BaseAnnotationMessenger) -> Void) { do { - let updatedAnnotation = annotation.toPointAnnotation() + var updatedAnnotation = annotation.toPointAnnotation() + updatedAnnotation.configureHandlers(controller: self, managerId: managerId) try update(annotation: updatedAnnotation, managerId: managerId) completion(.success(())) } catch { @@ -1523,5 +1492,41 @@ extension MapboxMaps.PointAnnotation { ) } } + +extension MapboxMaps.PointAnnotation { + mutating func configureHandlers(controller: PointAnnotationController, managerId: String) { + var configured = self + tapHandler = { [weak controller] _ in + let context = PointAnnotationInteractionContext( + annotation: configured.toFLTPointAnnotation(), + gestureState: .ended) + return controller?.tap(context, managerId: managerId) ?? false + } + longPressHandler = { [weak controller] _ in + let context = PointAnnotationInteractionContext( + annotation: configured.toFLTPointAnnotation(), + gestureState: .ended) + return controller?.longPress(context, managerId: managerId) ?? false + } + dragBeginHandler = { [weak controller] (annotation, _) in + let context = PointAnnotationInteractionContext( + annotation: annotation.toFLTPointAnnotation(), + gestureState: .started) + return controller?.drag(context, managerId: managerId) ?? false + } + dragChangeHandler = { [weak controller] (annotation, _) in + let context = PointAnnotationInteractionContext( + annotation: annotation.toFLTPointAnnotation(), + gestureState: .changed) + controller?.drag(context, managerId: managerId) + } + dragEndHandler = { [weak controller] (annotation, _) in + let context = PointAnnotationInteractionContext( + annotation: annotation.toFLTPointAnnotation(), + gestureState: .ended) + controller?.drag(context, managerId: managerId) + } + } +} // End of generated file. // swiftlint:enable file_length diff --git a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolygonAnnotationController.swift b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolygonAnnotationController.swift index 2b880a30..38af4bb8 100644 --- a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolygonAnnotationController.swift +++ b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolygonAnnotationController.swift @@ -23,39 +23,7 @@ final class PolygonAnnotationController: BaseAnnotationMessenger) -> Void) { do { - let updatedAnnotation = annotation.toPolygonAnnotation() + var updatedAnnotation = annotation.toPolygonAnnotation() + updatedAnnotation.configureHandlers(controller: self, managerId: managerId) try update(annotation: updatedAnnotation, managerId: managerId) completion(.success(())) } catch { @@ -434,5 +403,41 @@ extension MapboxMaps.PolygonAnnotation { ) } } + +extension MapboxMaps.PolygonAnnotation { + mutating func configureHandlers(controller: PolygonAnnotationController, managerId: String) { + var configured = self + tapHandler = { [weak controller] _ in + let context = PolygonAnnotationInteractionContext( + annotation: configured.toFLTPolygonAnnotation(), + gestureState: .ended) + return controller?.tap(context, managerId: managerId) ?? false + } + longPressHandler = { [weak controller] _ in + let context = PolygonAnnotationInteractionContext( + annotation: configured.toFLTPolygonAnnotation(), + gestureState: .ended) + return controller?.longPress(context, managerId: managerId) ?? false + } + dragBeginHandler = { [weak controller] (annotation, _) in + let context = PolygonAnnotationInteractionContext( + annotation: annotation.toFLTPolygonAnnotation(), + gestureState: .started) + return controller?.drag(context, managerId: managerId) ?? false + } + dragChangeHandler = { [weak controller] (annotation, _) in + let context = PolygonAnnotationInteractionContext( + annotation: annotation.toFLTPolygonAnnotation(), + gestureState: .changed) + controller?.drag(context, managerId: managerId) + } + dragEndHandler = { [weak controller] (annotation, _) in + let context = PolygonAnnotationInteractionContext( + annotation: annotation.toFLTPolygonAnnotation(), + gestureState: .ended) + controller?.drag(context, managerId: managerId) + } + } +} // End of generated file. // swiftlint:enable file_length diff --git a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolylineAnnotationController.swift b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolylineAnnotationController.swift index 0291005c..e01f9c0a 100644 --- a/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolylineAnnotationController.swift +++ b/ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/Annotations/PolylineAnnotationController.swift @@ -23,39 +23,7 @@ final class PolylineAnnotationController: BaseAnnotationMessenger) -> Void) { do { - let updatedAnnotation = annotation.toPolylineAnnotation() + var updatedAnnotation = annotation.toPolylineAnnotation() + updatedAnnotation.configureHandlers(controller: self, managerId: managerId) try update(annotation: updatedAnnotation, managerId: managerId) completion(.success(())) } catch { @@ -743,5 +712,41 @@ extension MapboxMaps.PolylineAnnotation { ) } } + +extension MapboxMaps.PolylineAnnotation { + mutating func configureHandlers(controller: PolylineAnnotationController, managerId: String) { + var configured = self + tapHandler = { [weak controller] _ in + let context = PolylineAnnotationInteractionContext( + annotation: configured.toFLTPolylineAnnotation(), + gestureState: .ended) + return controller?.tap(context, managerId: managerId) ?? false + } + longPressHandler = { [weak controller] _ in + let context = PolylineAnnotationInteractionContext( + annotation: configured.toFLTPolylineAnnotation(), + gestureState: .ended) + return controller?.longPress(context, managerId: managerId) ?? false + } + dragBeginHandler = { [weak controller] (annotation, _) in + let context = PolylineAnnotationInteractionContext( + annotation: annotation.toFLTPolylineAnnotation(), + gestureState: .started) + return controller?.drag(context, managerId: managerId) ?? false + } + dragChangeHandler = { [weak controller] (annotation, _) in + let context = PolylineAnnotationInteractionContext( + annotation: annotation.toFLTPolylineAnnotation(), + gestureState: .changed) + controller?.drag(context, managerId: managerId) + } + dragEndHandler = { [weak controller] (annotation, _) in + let context = PolylineAnnotationInteractionContext( + annotation: annotation.toFLTPolylineAnnotation(), + gestureState: .ended) + controller?.drag(context, managerId: managerId) + } + } +} // End of generated file. // swiftlint:enable file_length From 1c35972df601967c32ae8a480ac12e2ebb066d2b Mon Sep 17 00:00:00 2001 From: Roman Laitarenko Date: Tue, 11 Nov 2025 13:33:24 +0200 Subject: [PATCH 2/3] add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49bfad85..fde8574b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.17.0-rc.1 + +* [iOS] Fix annotation interaction handlers(tap, drag etc.) not working after annotation update. + ### 2.17.0-beta.1 > [!NOTE] From 21d5732165151698a4fd5c1331efbca40a5b5035 Mon Sep 17 00:00:00 2001 From: Roman Laitarenko Date: Tue, 11 Nov 2025 15:16:47 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md Co-authored-by: Patrick Leonard --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fde8574b..622fa314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ### 2.17.0-rc.1 -* [iOS] Fix annotation interaction handlers(tap, drag etc.) not working after annotation update. +* [iOS] Fix annotation interaction handlers (tap, drag etc.) not working after annotation update. ### 2.17.0-beta.1