Skip to content

Commit 5b38100

Browse files
committed
feat: add slot prop to PointAnnotation
1 parent 432d534 commit 5b38100

9 files changed

Lines changed: 53 additions & 19 deletions

File tree

android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotation.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.rnmapbox.rnmbx.v11compat.annotation.*;
2727
class RNMBXPointAnnotation(private val mContext: Context, private val mManager: RNMBXPointAnnotationManager) : AbstractMapFeature(mContext), View.OnLayoutChangeListener {
2828

2929
var pointAnnotations: RNMBXPointAnnotationCoordinator? = null
30+
var slot: String? = null
3031
var annotation: PointAnnotation? = null
3132
private set
3233
private var mMap: MapboxMap? = null
@@ -98,6 +99,7 @@ class RNMBXPointAnnotation(private val mContext: Context, private val mManager:
9899
super.addToMap(mapView)
99100
mMap = mapView.getMapboxMap()
100101
pointAnnotations = mapView.pointAnnotations
102+
slot?.let { pointAnnotations?.manager?.slot = it }
101103
makeMarker()
102104
if (mChildView != null) {
103105
if (!mChildView!!.isAttachedToWindow) {

android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotationManager.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ class RNMBXPointAnnotationManager(reactApplicationContext: ReactApplicationConte
9494
annotation.setDraggable(draggable.asBoolean())
9595
}
9696

97+
@ReactProp(name = "slot")
98+
override fun setSlot(annotation: RNMBXPointAnnotation, slot: Dynamic) {
99+
if (!slot.isNull) {
100+
annotation.slot = slot.asString()
101+
annotation.pointAnnotations?.manager?.slot = slot.asString()
102+
}
103+
}
104+
97105
companion object {
98106
const val REACT_CLASS = "RNMBXPointAnnotation"
99107
}

docs/PointAnnotation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ This callback is fired while this annotation is being dragged.
144144

145145

146146

147+
### slot
148+
149+
```tsx
150+
'bottom' | 'middle' | 'top' | string
151+
```
152+
The slot in the Standard style to position the annotation layer.
153+
Use with Mapbox Standard style to control layer ordering.
154+
155+
156+
147157
### children
148158

149159
```tsx

docs/StyleImport.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ existing is now always required as true
3838
### config
3939

4040
```tsx
41-
type Config = {
42-
[object Object]: string; /* FIX ME NO DESCRIPTION */
43-
}
41+
intersection
4442
```
4543
_required_
4644
config is a dictionary of configuration options for the style import.
4745

46+
When using the Mapbox Standard style with `id="basemap"`, use {@link StandardStyleConfig}
47+
keys for autocomplete. Arbitrary keys are also accepted for forward compatibility.
48+
4849
See https://github.com/mapbox/mapbox-maps-ios/blob/main/Sources/MapboxMaps/Documentation.docc/Migrate%20to%20v11.md#21-the-mapbox-standard-style
4950

5051

docs/docs.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6510,6 +6510,13 @@
65106510
"default": "none",
65116511
"description": "This callback is fired while this annotation is being dragged.\n*signature:*`(payload:Feature) => void`"
65126512
},
6513+
{
6514+
"name": "slot",
6515+
"required": false,
6516+
"type": "'bottom' \\| 'middle' \\| 'top' \\| string",
6517+
"default": "none",
6518+
"description": "The slot in the Standard style to position the annotation layer.\nUse with Mapbox Standard style to control layer ordering."
6519+
},
65136520
{
65146521
"name": "children",
65156522
"required": true,
@@ -8126,22 +8133,9 @@
81268133
{
81278134
"name": "config",
81288135
"required": true,
8129-
"type": {
8130-
"name": "shape",
8131-
"value": [
8132-
{
8133-
"name": {
8134-
"name": "string"
8135-
},
8136-
"required": true,
8137-
"type": "string",
8138-
"default": "none",
8139-
"description": "FIX ME NO DESCRIPTION"
8140-
}
8141-
]
8142-
},
8136+
"type": "intersection",
81438137
"default": "none",
8144-
"description": "config is a dictionary of configuration options for the style import.\n\nSee https://github.com/mapbox/mapbox-maps-ios/blob/main/Sources/MapboxMaps/Documentation.docc/Migrate%20to%20v11.md#21-the-mapbox-standard-style"
8138+
"description": "config is a dictionary of configuration options for the style import.\n\nWhen using the Mapbox Standard style with `id=\"basemap\"`, use {@link StandardStyleConfig}\nkeys for autocomplete. Arbitrary keys are also accepted for forward compatibility.\n\nSee https://github.com/mapbox/mapbox-maps-ios/blob/main/Sources/MapboxMaps/Documentation.docc/Migrate%20to%20v11.md#21-the-mapbox-standard-style"
81458139
}
81468140
],
81478141
"fileNameWithExt": "StyleImport.tsx",

ios/RNMBX/RNMBXPointAnnotation.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public class RNMBXPointAnnotation : RNMBXInteractiveElement {
2929
var reactSubviews : [UIView] = []
3030

3131

32+
@objc public var slot: String? {
33+
didSet {
34+
if let slot = slot {
35+
map?.pointAnnotationManager.manager.slot = Slot(rawValue: slot)
36+
}
37+
}
38+
}
39+
3240
@objc public var onDeselected: RCTBubblingEventBlock? = nil
3341
@objc public var onDrag: RCTBubblingEventBlock? = nil
3442
@objc public var onDragEnd: RCTBubblingEventBlock? = nil
@@ -274,6 +282,9 @@ public class RNMBXPointAnnotation : RNMBXInteractiveElement {
274282

275283
public override func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
276284
super.addToMap(map, mapView: mapView, style: style)
285+
if let slot = slot {
286+
map.pointAnnotationManager.manager.slot = Slot(rawValue: slot)
287+
}
277288
addIfPossible()
278289
}
279290

ios/RNMBX/RNMBXPointAnnotationComponentView.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
131131
RNMBX_OPTIONAL_PROP_NSString(id)
132132
RNMBX_OPTIONAL_PROP_NSDictionary(anchor)
133133
RNMBX_REMAP_OPTIONAL_PROP_BOOL(selected, reactSelected)
134+
RNMBX_OPTIONAL_PROP_NSString(slot)
134135

135136
[super updateProps:props oldProps:oldProps];
136137
}

src/components/PointAnnotation.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ type Props = BaseProps & {
104104
*/
105105
onDrag?: (payload: FeaturePayload) => void;
106106

107+
/**
108+
* The slot in the Standard style to position the annotation layer.
109+
* Use with Mapbox Standard style to control layer ordering.
110+
*/
111+
slot?: 'bottom' | 'middle' | 'top' | string;
112+
107113
/**
108114
* Expects one child, and an optional callout can be added as well
109115
*/

src/specs/RNMBXPointAnnotationNativeComponent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNati
33
// @ts-ignore - CI environment type resolution issue for CodegenTypes
44
import { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
55

6-
import type { UnsafeMixed } from './codegenUtils';
6+
import type { OptionalProp, UnsafeMixed } from './codegenUtils';
77

88
type OnMapboxPointAnnotationDeselectedEventType = {
99
type: string;
@@ -29,6 +29,7 @@ export interface NativeProps extends ViewProps {
2929
id: UnsafeMixed<string>;
3030
anchor: UnsafeMixed<any>;
3131
selected: UnsafeMixed<boolean>;
32+
slot: OptionalProp<string>;
3233

3334
onMapboxPointAnnotationDeselected: DirectEventHandler<OnMapboxPointAnnotationDeselectedEventType>;
3435
onMapboxPointAnnotationDrag: DirectEventHandler<OnMapboxPointAnnotationDragEventType>;

0 commit comments

Comments
 (0)