mapbox / mapbox/mapbox-maps-ios
PointAnnotationManager overlap settings not working
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
Environment
- Xcode version: 15.0.1
- iOS version: iOS 17.0.1
- Devices affected: iPhone 15 sim
- Maps SDK Version: 11.0.2
Observed behavior and steps to reproduce
My goal was to have text hidden when overlapping any part of another PointAnnotation, but always show the image. It's possible I am conflating icon and image here, but even-so I'd expect with turning all to overlap = false for no overlaps to be allowed?
Configure the PointAnnotationManager with textAllowOverlap or iconAllowOverlap do not seem to modify PointAnnotation behavior
Simplified Code
func setupDropPinAtCameraCenter() {
manager = mapView.annotations.makePointAnnotationManager(id: "camera-points")
manager.textAllowOverlap = false
manager.iconAllowOverlap = false
manager.textOptional = true
mapView.mapboxMap.onCameraChanged
.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main)
.sink { [weak self] cameraChanged in
guard let self else { return }
guard mapView.mapboxMap.isStyleLoaded else {
return
}
self.dropPinAtCameraCenter()
}.store(in: &bag)
}
func dropPinAtCameraCenter() {
let center = mapView.mapboxMap.cameraState.center
let annotation = makePointAnnotation(id: UUID().uuidString, coordinate: center)
manager.annotations = manager.annotations + [annotation]
}
func makePointAnnotation(id: String, coordinate: CLLocationCoordinate2D) -> PointAnnotation {
var annotation = PointAnnotation(id: id, coordinate: coordinate)
let image = UIImage(named: "canyon_pin")!
annotation.image = PointAnnotation.Image(image: image, name: "canyon_pin")
annotation.textField = "Center Camera Pin"
annotation.iconAnchor = .bottom
annotation.iconOffset = [0, -12]
return annotation
}
Expected behavior
I expected with both overlap options to false that only non-overlapping PointAnnotation text/image would be shown.
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 PointAnnotationManager's textAllowOverlap, iconAllowOverlap, and textOptional settings, then reproduce the simplified setup on iOS 17.0.1 with Maps SDK 11.0.2. Done means establishing whether text and image overlap behavior matches the stated expectations and fixing or documenting the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100