Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.rnmapbox.rnmbx.v11compat.annotation.*;
class RNMBXPointAnnotation(private val mContext: Context, private val mManager: RNMBXPointAnnotationManager) : AbstractMapFeature(mContext), View.OnLayoutChangeListener {

var pointAnnotations: RNMBXPointAnnotationCoordinator? = null
var slot: String? = null
var annotation: PointAnnotation? = null
private set
private var mMap: MapboxMap? = null
Expand Down Expand Up @@ -98,6 +99,7 @@ class RNMBXPointAnnotation(private val mContext: Context, private val mManager:
super.addToMap(mapView)
mMap = mapView.getMapboxMap()
pointAnnotations = mapView.pointAnnotations
slot?.let { pointAnnotations?.manager?.slot = it }
makeMarker()
if (mChildView != null) {
if (!mChildView!!.isAttachedToWindow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class RNMBXPointAnnotationManager(reactApplicationContext: ReactApplicationConte
annotation.setDraggable(draggable.asBoolean())
}

@ReactProp(name = "slot")
override fun setSlot(annotation: RNMBXPointAnnotation, slot: Dynamic) {
if (!slot.isNull) {
annotation.slot = slot.asString()
annotation.pointAnnotations?.manager?.slot = slot.asString()
}
}

companion object {
const val REACT_CLASS = "RNMBXPointAnnotation"
}
Expand Down
10 changes: 10 additions & 0 deletions docs/PointAnnotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ This callback is fired while this annotation is being dragged.



### slot

```tsx
'bottom' | 'middle' | 'top' | string
```
The slot in the Standard style to position the annotation layer.
Use with Mapbox Standard style to control layer ordering.



### children

```tsx
Expand Down
7 changes: 7 additions & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6510,6 +6510,13 @@
"default": "none",
"description": "This callback is fired while this annotation is being dragged.\n*signature:*`(payload:Feature) => void`"
},
{
"name": "slot",
"required": false,
"type": "'bottom' \\| 'middle' \\| 'top' \\| string",
"default": "none",
"description": "The slot in the Standard style to position the annotation layer.\nUse with Mapbox Standard style to control layer ordering."
},
{
"name": "children",
"required": true,
Expand Down
11 changes: 11 additions & 0 deletions ios/RNMBX/RNMBXPointAnnotation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public class RNMBXPointAnnotation : RNMBXInteractiveElement {
var reactSubviews : [UIView] = []


@objc public var slot: String? {
didSet {
if let slot = slot {
map?.pointAnnotationManager.manager.slot = Slot(rawValue: slot)
}
}
}

@objc public var onDeselected: RCTBubblingEventBlock? = nil
@objc public var onDrag: RCTBubblingEventBlock? = nil
@objc public var onDragEnd: RCTBubblingEventBlock? = nil
Expand Down Expand Up @@ -274,6 +282,9 @@ public class RNMBXPointAnnotation : RNMBXInteractiveElement {

public override func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
super.addToMap(map, mapView: mapView, style: style)
if let slot = slot {
map.pointAnnotationManager.manager.slot = Slot(rawValue: slot)
}
addIfPossible()
}

Expand Down
1 change: 1 addition & 0 deletions ios/RNMBX/RNMBXPointAnnotationComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
RNMBX_OPTIONAL_PROP_NSString(id)
RNMBX_OPTIONAL_PROP_NSDictionary(anchor)
RNMBX_REMAP_OPTIONAL_PROP_BOOL(selected, reactSelected)
RNMBX_OPTIONAL_PROP_NSString(slot)

[super updateProps:props oldProps:oldProps];
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/PointAnnotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ type Props = BaseProps & {
*/
onDrag?: (payload: FeaturePayload) => void;

/**
* The slot in the Standard style to position the annotation layer.
* Use with Mapbox Standard style to control layer ordering.
*/
slot?: 'bottom' | 'middle' | 'top' | string;

/**
* Expects one child, and an optional callout can be added as well
*/
Expand Down
6 changes: 6 additions & 0 deletions src/specs/RNMBXPointAnnotationNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

type Slot = 'bottom' | 'middle' | 'top';

type OnMapboxPointAnnotationDeselectedEventType = {
type: string;
payload: string;
Expand All @@ -29,6 +34,7 @@ export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
anchor: UnsafeMixed<any>;
selected: UnsafeMixed<boolean>;
slot?: OptionalProp<Slot>;

onMapboxPointAnnotationDeselected: DirectEventHandler<OnMapboxPointAnnotationDeselectedEventType>;
onMapboxPointAnnotationDrag: DirectEventHandler<OnMapboxPointAnnotationDragEventType>;
Expand Down
Loading