mapbox / mapbox/mapbox-maps-ios
Support isDraggable, dragBeginHandler, dragChangeHandler, dragEndHandler for PointAnnotation in SwiftUI
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## New Feature
Currently I see that I can set isDraggable in the PointAnnotation is in the initialiser:
```
/// Create a point annotation with a coordinate and an optional identifier
/// - Parameters:
/// - id: Optional identifier for this annotation
/// - coordinate: Coordinate where this annotation should be rendered
/// - isDraggable: Determines whether annotation can be manually moved around map
/// - isSelected: Passes the annotation's selection state
public init(id: String = UUID().uuidString, coordinate: CLLocationCoordinate2D, isSelected: Bool = false, isDraggable: Bool = false) {
let point = Point(coordinate)
self.init(id: id, point: point, isSelected: isSelected, isDraggable: isDraggable)
}
```
... but it does not seem to do anything in SwiftUI.
In the PointAnnotation.swift file it is even mentioned that this is not supported in SwiftUI:
`
/// - Note: In SwiftUI, draggable annotations are not supported.
`
## Why
I would like to allow the people who use my SwiftUI app to drag PointAnnotations on the Map.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with PointAnnotation.swift and inspect the existing isDraggable initializer and the SwiftUI limitation noted there. Trace how PointAnnotation exposes annotation interactions, then add support for dragBeginHandler, dragChangeHandler, and dragEndHandler; done means SwiftUI users can drag PointAnnotations and receive those handlers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100