Skip to content

Commit 2e9007d

Browse files
authored
Add ViewAnnotationOptions.priority (#2398)
1 parent ee0465d commit 2e9007d

File tree

21 files changed

+247
-49
lines changed

21 files changed

+247
-49
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ CircleAnnotationGroup {}
2222
// new
2323
.slot(.middle)
2424
```
25+
* Introduce `ViewAnnotation.priority`, deprecate `ViewAnnotation.selected`.
26+
Use this property to define view annotation sort order.
27+
* Introduce `ViewAnnotation.minZoom` and `ViewAnnotation.maxZoom`. Use these properties to configure zoom-level specific view annotations.
28+
* Update CoreMaps to 11.10.0-beta.2 and Common to 24.10.0-beta.2.
2529

2630
## 11.9.0 - 18 December, 2024
2731

Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MapboxMaps.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Pod::Spec.new do |m|
2121
m.source_files = 'Sources/MapboxMaps/**/*.{swift,h}'
2222
m.resource_bundles = { 'MapboxMapsResources' => ['Sources/**/*.{xcassets,strings}', 'Sources/MapboxMaps/MapboxMaps.json', 'Sources/MapboxMaps/PrivacyInfo.xcprivacy'] }
2323

24-
m.dependency 'MapboxCoreMaps', '11.9.0'
25-
m.dependency 'MapboxCommon', '24.9.0'
24+
m.dependency 'MapboxCoreMaps', '11.10.0-beta.2'
25+
m.dependency 'MapboxCommon', '24.10.0-beta.2'
2626
m.dependency 'Turf', '4.0.0'
2727

2828
end

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import PackageDescription
55
import Foundation
66

7-
let coreMaps = MapsDependency.coreMaps(version: "11.9.0")
7+
let coreMaps = MapsDependency.coreMaps(version: "11.10.0-beta.2")
88

9-
let common = MapsDependency.common(version: "24.9.0")
9+
let common = MapsDependency.common(version: "24.10.0-beta.2")
1010

1111
let mapboxMapsPath: String? = nil
1212

Sources/Examples/All Examples/Annotations/DynamicViewAnnotationExample.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ final class DynamicViewAnnotationExample: UIViewController, ExampleProtocol {
7979

8080
addParkingAnnotation(
8181
coordinate: CLLocationCoordinate2D(latitude: 37.445, longitude: -122.1704),
82-
text: "$6.99/hr")
82+
text: "$6.99/hr",
83+
minZoom: 12)
8384
addParkingAnnotation(
8485
coordinate: CLLocationCoordinate2D(latitude: 37.4441, longitude: -122.1691),
85-
text: "$5.99/hr")
86+
text: "$5.99/hr",
87+
minZoom: 10)
8688
}
8789

8890
private func loadRoutes() {
@@ -161,16 +163,17 @@ final class DynamicViewAnnotationExample: UIViewController, ExampleProtocol {
161163
}
162164
}
163165

164-
private func addParkingAnnotation(coordinate: CLLocationCoordinate2D, text: String) {
166+
private func addParkingAnnotation(coordinate: CLLocationCoordinate2D, text: String, minZoom: Double) {
165167
let view = ParkingAnnotationView(text: text)
166168

167169
let annotation = ViewAnnotation(coordinate: coordinate, view: view)
168170
annotation.allowOverlap = true
171+
annotation.minZoom = minZoom
169172
mapView.viewAnnotations.add(annotation)
170173

171174
view.onTap = { [unowned view, unowned annotation] in
172-
annotation.selected.toggle()
173-
view.selected = annotation.selected
175+
view.selected.toggle()
176+
annotation.priority = view.selected ? 1 : 0
174177
annotation.setNeedsUpdateSize()
175178
}
176179
}
@@ -261,6 +264,7 @@ private final class Route {
261264
etaView.anchor = config.anchor
262265
}
263266
etaAnnotation.variableAnchors = .all
267+
etaAnnotation.minZoom = 8
264268
etaView.onTap = { [weak self] in self?.onTap?() }
265269

266270
self.etaAnnotation = etaAnnotation
@@ -290,7 +294,7 @@ private final class Route {
290294
}
291295

292296
private func updateSelected() {
293-
etaAnnotation?.selected = selected
297+
etaAnnotation?.priority = selected ? 1 : 0
294298
etaView?.selected = selected
295299
mapView?.mapboxMap.setFeatureState(sourceId: layerId, featureId: name, state: ["selected": selected]) {_ in}
296300

Sources/Examples/All Examples/Annotations/ViewAnnotationBasicExample.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class ViewAnnotationBasicExample: UIViewController, ExampleProtocol {
3535
annotation.allowOverlap = true
3636
annotationView.onClose = { [weak annotation] in annotation?.remove() }
3737
annotationView.onSelect = { [weak annotation] selected in
38-
annotation?.selected = selected
38+
annotation?.priority = selected ? 1 : 0
3939
annotation?.setNeedsUpdateSize()
4040
}
4141
mapView.viewAnnotations.add(annotation)

Sources/Examples/All Examples/Annotations/ViewAnnotationMarkerExample.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ final class ViewAnnotationMarkerExample: UIViewController, ExampleProtocol {
77
private var pointList: [Feature] = []
88
private var markerId = 0
99
private var annotations = [String: ViewAnnotation]()
10+
private var _topPriority = 0
11+
private var topPriority: Int {
12+
_topPriority += 1
13+
return _topPriority
14+
}
1015

1116
private let image = UIImage(named: "intermediate-pin")!
1217
private lazy var markerHeight: CGFloat = image.size.height
@@ -68,7 +73,7 @@ final class ViewAnnotationMarkerExample: UIViewController, ExampleProtocol {
6873
guard case let .string(id) = feature.identifier else { return false }
6974

7075
if let annotation = annotations[id] {
71-
annotation.visible.toggle()
76+
annotation.priority = topPriority
7277
return true
7378
}
7479
return addViewAnnotation(to: feature)
@@ -141,8 +146,9 @@ final class ViewAnnotationMarkerExample: UIViewController, ExampleProtocol {
141146
annotation?.remove()
142147
self?.annotations.removeValue(forKey: id)
143148
}
144-
annotationView.onSelect = { [weak annotation] selected in
145-
annotation?.selected = selected
149+
annotationView.onSelect = { [weak annotation, weak self] _ in
150+
guard let self else { return }
151+
annotation?.priority = self.topPriority
146152
annotation?.setNeedsUpdateSize()
147153
}
148154

Sources/Examples/All Examples/Annotations/ViewAnnotationWithPointAnnotationExample.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ final class ViewAnnotationWithPointAnnotationExample: UIViewController, ExampleP
7070
annotation?.remove()
7171
self?.annotation = nil
7272
}
73-
annotationView.onSelect = { [weak annotation] selected in
74-
annotation?.selected = selected
73+
annotationView.onSelect = { [weak annotation] _ in
7574
annotation?.setNeedsUpdateSize()
7675
}
7776
self.annotation = annotation

0 commit comments

Comments
 (0)