Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 2.17.0-rc.1

* [iOS] Fix annotation interaction handlers (tap, drag etc.) not working after annotation update.
* Add the ability to get all annotations from an annotation manager.
* Add `customData` field to annotations to be able to pass user data.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,7 @@ final class CircleAnnotationController: BaseAnnotationMessenger<CircleAnnotation
do {
let annotations = annotationOptions.map({ options in
var annotation = options.toCircleAnnotation()
annotation.tapHandler = { [weak self] (context) in
guard let self else { return false }
let context = CircleAnnotationInteractionContext(
annotation: annotation.toFLTCircleAnnotation(),
gestureState: .ended)
return self.tap(context, managerId: managerId)
}
annotation.longPressHandler = { [weak self] (context) in
guard let self else { return false }
let context = CircleAnnotationInteractionContext(
annotation: annotation.toFLTCircleAnnotation(),
gestureState: .ended)
return self.longPress(context, managerId: managerId)
}
annotation.dragBeginHandler = { [weak self] (annotation, context) in
guard let self else { return false }
let context = CircleAnnotationInteractionContext(
annotation: annotation.toFLTCircleAnnotation(),
gestureState: .started)
return self.drag(context, managerId: managerId)
}
annotation.dragChangeHandler = { [weak self] (annotation, context) in
let context = CircleAnnotationInteractionContext(
annotation: annotation.toFLTCircleAnnotation(),
gestureState: .changed)
self?.drag(context, managerId: managerId)
}
annotation.dragEndHandler = { [weak self] (annotation, context) in
let context = CircleAnnotationInteractionContext(
annotation: annotation.toFLTCircleAnnotation(),
gestureState: .ended)
self?.drag(context, managerId: managerId)
}
annotation.configureHandlers(controller: self, managerId: managerId)
return annotation
})
try append(annotations, managerId: managerId)
Expand All @@ -71,7 +39,8 @@ final class CircleAnnotationController: BaseAnnotationMessenger<CircleAnnotation

func update(managerId: String, annotation: CircleAnnotation, completion: @escaping (Result<Void, Error>) -> 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 {
Expand Down Expand Up @@ -438,5 +407,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
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,7 @@ final class PointAnnotationController: BaseAnnotationMessenger<PointAnnotationMa
do {
let annotations = annotationOptions.map({ options in
var annotation = options.toPointAnnotation()
annotation.tapHandler = { [weak self] (context) in
guard let self else { return false }
let context = PointAnnotationInteractionContext(
annotation: annotation.toFLTPointAnnotation(),
gestureState: .ended)
return self.tap(context, managerId: managerId)
}
annotation.longPressHandler = { [weak self] (context) in
guard let self else { return false }
let context = PointAnnotationInteractionContext(
annotation: annotation.toFLTPointAnnotation(),
gestureState: .ended)
return self.longPress(context, managerId: managerId)
}
annotation.dragBeginHandler = { [weak self] (annotation, context) in
guard let self else { return false }
let context = PointAnnotationInteractionContext(
annotation: annotation.toFLTPointAnnotation(),
gestureState: .started)
return self.drag(context, managerId: managerId)
}
annotation.dragChangeHandler = { [weak self] (annotation, context) in
let context = PointAnnotationInteractionContext(
annotation: annotation.toFLTPointAnnotation(),
gestureState: .changed)
self?.drag(context, managerId: managerId)
}
annotation.dragEndHandler = { [weak self] (annotation, context) in
let context = PointAnnotationInteractionContext(
annotation: annotation.toFLTPointAnnotation(),
gestureState: .ended)
self?.drag(context, managerId: managerId)
}
annotation.configureHandlers(controller: self, managerId: managerId)
return annotation
})
try append(annotations, managerId: managerId)
Expand All @@ -71,7 +39,8 @@ final class PointAnnotationController: BaseAnnotationMessenger<PointAnnotationMa

func update(managerId: String, annotation: PointAnnotation, completion: @escaping (Result<Void, Error>) -> 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 {
Expand Down Expand Up @@ -1534,5 +1503,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
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,7 @@ final class PolygonAnnotationController: BaseAnnotationMessenger<PolygonAnnotati
do {
let annotations = annotationOptions.map({ options in
var annotation = options.toPolygonAnnotation()
annotation.tapHandler = { [weak self] (context) in
guard let self else { return false }
let context = PolygonAnnotationInteractionContext(
annotation: annotation.toFLTPolygonAnnotation(),
gestureState: .ended)
return self.tap(context, managerId: managerId)
}
annotation.longPressHandler = { [weak self] (context) in
guard let self else { return false }
let context = PolygonAnnotationInteractionContext(
annotation: annotation.toFLTPolygonAnnotation(),
gestureState: .ended)
return self.longPress(context, managerId: managerId)
}
annotation.dragBeginHandler = { [weak self] (annotation, context) in
guard let self else { return false }
let context = PolygonAnnotationInteractionContext(
annotation: annotation.toFLTPolygonAnnotation(),
gestureState: .started)
return self.drag(context, managerId: managerId)
}
annotation.dragChangeHandler = { [weak self] (annotation, context) in
let context = PolygonAnnotationInteractionContext(
annotation: annotation.toFLTPolygonAnnotation(),
gestureState: .changed)
self?.drag(context, managerId: managerId)
}
annotation.dragEndHandler = { [weak self] (annotation, context) in
let context = PolygonAnnotationInteractionContext(
annotation: annotation.toFLTPolygonAnnotation(),
gestureState: .ended)
self?.drag(context, managerId: managerId)
}
annotation.configureHandlers(controller: self, managerId: managerId)
return annotation
})
try append(annotations, managerId: managerId)
Expand All @@ -71,7 +39,8 @@ final class PolygonAnnotationController: BaseAnnotationMessenger<PolygonAnnotati

func update(managerId: String, annotation: PolygonAnnotation, completion: @escaping (Result<Void, Error>) -> 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 {
Expand Down Expand Up @@ -445,5 +414,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
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,7 @@ final class PolylineAnnotationController: BaseAnnotationMessenger<PolylineAnnota
do {
let annotations = annotationOptions.map({ options in
var annotation = options.toPolylineAnnotation()
annotation.tapHandler = { [weak self] (context) in
guard let self else { return false }
let context = PolylineAnnotationInteractionContext(
annotation: annotation.toFLTPolylineAnnotation(),
gestureState: .ended)
return self.tap(context, managerId: managerId)
}
annotation.longPressHandler = { [weak self] (context) in
guard let self else { return false }
let context = PolylineAnnotationInteractionContext(
annotation: annotation.toFLTPolylineAnnotation(),
gestureState: .ended)
return self.longPress(context, managerId: managerId)
}
annotation.dragBeginHandler = { [weak self] (annotation, context) in
guard let self else { return false }
let context = PolylineAnnotationInteractionContext(
annotation: annotation.toFLTPolylineAnnotation(),
gestureState: .started)
return self.drag(context, managerId: managerId)
}
annotation.dragChangeHandler = { [weak self] (annotation, context) in
let context = PolylineAnnotationInteractionContext(
annotation: annotation.toFLTPolylineAnnotation(),
gestureState: .changed)
self?.drag(context, managerId: managerId)
}
annotation.dragEndHandler = { [weak self] (annotation, context) in
let context = PolylineAnnotationInteractionContext(
annotation: annotation.toFLTPolylineAnnotation(),
gestureState: .ended)
self?.drag(context, managerId: managerId)
}
annotation.configureHandlers(controller: self, managerId: managerId)
return annotation
})
try append(annotations, managerId: managerId)
Expand All @@ -71,7 +39,8 @@ final class PolylineAnnotationController: BaseAnnotationMessenger<PolylineAnnota

func update(managerId: String, annotation: PolylineAnnotation, completion: @escaping (Result<Void, Error>) -> 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 {
Expand Down Expand Up @@ -754,5 +723,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