@maplibre/maplibre-react-native 11.0.0-alpha.42 → 11.0.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/android/build.gradle +1 -3
  2. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +3 -3
  3. package/android/src/main/java/org/maplibre/reactnative/components/annotations/callout/MLRNCallout.kt +7 -0
  4. package/android/src/main/java/org/maplibre/reactnative/components/annotations/callout/MLRNCalloutManager.kt +29 -0
  5. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerView.kt +220 -0
  6. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerViewContent.kt +50 -0
  7. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerViewManager.kt +81 -0
  8. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MarkerViewManager.kt +127 -0
  9. package/android/src/main/java/org/maplibre/reactnative/components/annotations/pointannotation/MLRNPointAnnotation.kt +407 -0
  10. package/android/src/main/java/org/maplibre/reactnative/components/annotations/pointannotation/MLRNPointAnnotationManager.kt +105 -0
  11. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +38 -37
  12. package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationClickEvent.java +1 -1
  13. package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationDragEvent.java +1 -1
  14. package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationEvent.kt +30 -0
  15. package/ios/components/annotations/callout/MLRNCalloutComponentView.h +10 -0
  16. package/ios/components/annotations/callout/MLRNCalloutComponentView.mm +91 -0
  17. package/ios/components/annotations/point-annotation/MLRNPointAnnotation.h +44 -0
  18. package/ios/components/annotations/{MLRNPointAnnotation.m → point-annotation/MLRNPointAnnotation.m} +69 -35
  19. package/ios/components/annotations/point-annotation/MLRNPointAnnotationComponentView.h +10 -0
  20. package/ios/components/annotations/point-annotation/MLRNPointAnnotationComponentView.mm +331 -0
  21. package/ios/components/map-view/MLRNMapView.m +4 -5
  22. package/lib/commonjs/components/annotations/callout/Callout.js +94 -0
  23. package/lib/commonjs/components/annotations/callout/Callout.js.map +1 -0
  24. package/lib/commonjs/components/annotations/callout/CalloutNativeComponent.ts +11 -0
  25. package/lib/commonjs/components/annotations/marker-view/MarkerView.js +70 -0
  26. package/lib/commonjs/components/annotations/marker-view/MarkerView.js.map +1 -0
  27. package/lib/commonjs/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
  28. package/lib/commonjs/components/annotations/point-annotation/PointAnnotation.js +88 -0
  29. package/lib/commonjs/components/annotations/point-annotation/PointAnnotation.js.map +1 -0
  30. package/lib/commonjs/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
  31. package/lib/commonjs/index.js +3 -3
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/types/Anchor.js +68 -0
  34. package/lib/commonjs/types/Anchor.js.map +1 -0
  35. package/lib/commonjs/utils/animated/Animated.js +4 -0
  36. package/lib/commonjs/utils/animated/Animated.js.map +1 -1
  37. package/lib/module/components/annotations/callout/Callout.js +88 -0
  38. package/lib/module/components/annotations/callout/Callout.js.map +1 -0
  39. package/lib/module/components/annotations/callout/CalloutNativeComponent.ts +11 -0
  40. package/lib/module/components/annotations/marker-view/MarkerView.js +64 -0
  41. package/lib/module/components/annotations/marker-view/MarkerView.js.map +1 -0
  42. package/lib/module/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
  43. package/lib/module/components/annotations/point-annotation/PointAnnotation.js +83 -0
  44. package/lib/module/components/annotations/point-annotation/PointAnnotation.js.map +1 -0
  45. package/lib/module/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
  46. package/lib/module/index.js +3 -3
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/types/Anchor.js +64 -0
  49. package/lib/module/types/Anchor.js.map +1 -0
  50. package/lib/module/utils/animated/Animated.js +4 -0
  51. package/lib/module/utils/animated/Animated.js.map +1 -1
  52. package/lib/typescript/{module/src/components/annotations → commonjs/src/components/annotations/callout}/Callout.d.ts +9 -9
  53. package/lib/typescript/commonjs/src/components/annotations/callout/Callout.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/src/components/annotations/callout/CalloutNativeComponent.d.ts +6 -0
  55. package/lib/typescript/commonjs/src/components/annotations/callout/CalloutNativeComponent.d.ts.map +1 -0
  56. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerView.d.ts +52 -0
  57. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerView.d.ts.map +1 -0
  58. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts +21 -0
  59. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts.map +1 -0
  60. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotation.d.ts +95 -0
  61. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotation.d.ts.map +1 -0
  62. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts +43 -0
  63. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts.map +1 -0
  64. package/lib/typescript/commonjs/src/index.d.ts +4 -4
  65. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/src/types/Anchor.d.ts +17 -0
  67. package/lib/typescript/commonjs/src/types/Anchor.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +1 -0
  69. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
  70. package/lib/typescript/{commonjs/src/components/annotations → module/src/components/annotations/callout}/Callout.d.ts +9 -9
  71. package/lib/typescript/module/src/components/annotations/callout/Callout.d.ts.map +1 -0
  72. package/lib/typescript/module/src/components/annotations/callout/CalloutNativeComponent.d.ts +6 -0
  73. package/lib/typescript/module/src/components/annotations/callout/CalloutNativeComponent.d.ts.map +1 -0
  74. package/lib/typescript/module/src/components/annotations/marker-view/MarkerView.d.ts +52 -0
  75. package/lib/typescript/module/src/components/annotations/marker-view/MarkerView.d.ts.map +1 -0
  76. package/lib/typescript/module/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts +21 -0
  77. package/lib/typescript/module/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts.map +1 -0
  78. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotation.d.ts +95 -0
  79. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotation.d.ts.map +1 -0
  80. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts +43 -0
  81. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts.map +1 -0
  82. package/lib/typescript/module/src/index.d.ts +4 -4
  83. package/lib/typescript/module/src/index.d.ts.map +1 -1
  84. package/lib/typescript/module/src/types/Anchor.d.ts +17 -0
  85. package/lib/typescript/module/src/types/Anchor.d.ts.map +1 -0
  86. package/lib/typescript/module/src/utils/animated/Animated.d.ts +1 -0
  87. package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
  88. package/package.json +3 -1
  89. package/src/components/annotations/callout/Callout.tsx +145 -0
  90. package/src/components/annotations/callout/CalloutNativeComponent.ts +11 -0
  91. package/src/components/annotations/marker-view/MarkerView.tsx +124 -0
  92. package/src/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
  93. package/src/components/annotations/point-annotation/PointAnnotation.tsx +219 -0
  94. package/src/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
  95. package/src/index.ts +15 -4
  96. package/src/types/Anchor.ts +44 -0
  97. package/src/utils/animated/Animated.tsx +6 -0
  98. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNCallout.java +0 -11
  99. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNCalloutManager.java +0 -18
  100. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNMarkerView.java +0 -112
  101. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNMarkerViewManager.java +0 -45
  102. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNPointAnnotation.java +0 -361
  103. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNPointAnnotationManager.java +0 -84
  104. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MarkerView.java +0 -23
  105. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MarkerViewManager.java +0 -69
  106. package/ios/components/annotations/MLRNCalloutManager.h +0 -5
  107. package/ios/components/annotations/MLRNCalloutManager.m +0 -12
  108. package/ios/components/annotations/MLRNPointAnnotation.h +0 -33
  109. package/ios/components/annotations/MLRNPointAnnotationManager.h +0 -5
  110. package/ios/components/annotations/MLRNPointAnnotationManager.m +0 -27
  111. package/lib/commonjs/components/annotations/Callout.js +0 -101
  112. package/lib/commonjs/components/annotations/Callout.js.map +0 -1
  113. package/lib/commonjs/components/annotations/MarkerView.js +0 -60
  114. package/lib/commonjs/components/annotations/MarkerView.js.map +0 -1
  115. package/lib/commonjs/components/annotations/PointAnnotation.js +0 -114
  116. package/lib/commonjs/components/annotations/PointAnnotation.js.map +0 -1
  117. package/lib/module/components/annotations/Callout.js +0 -96
  118. package/lib/module/components/annotations/Callout.js.map +0 -1
  119. package/lib/module/components/annotations/MarkerView.js +0 -55
  120. package/lib/module/components/annotations/MarkerView.js.map +0 -1
  121. package/lib/module/components/annotations/PointAnnotation.js +0 -110
  122. package/lib/module/components/annotations/PointAnnotation.js.map +0 -1
  123. package/lib/typescript/commonjs/src/components/annotations/Callout.d.ts.map +0 -1
  124. package/lib/typescript/commonjs/src/components/annotations/MarkerView.d.ts +0 -44
  125. package/lib/typescript/commonjs/src/components/annotations/MarkerView.d.ts.map +0 -1
  126. package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts +0 -90
  127. package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts.map +0 -1
  128. package/lib/typescript/module/src/components/annotations/Callout.d.ts.map +0 -1
  129. package/lib/typescript/module/src/components/annotations/MarkerView.d.ts +0 -44
  130. package/lib/typescript/module/src/components/annotations/MarkerView.d.ts.map +0 -1
  131. package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts +0 -90
  132. package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts.map +0 -1
  133. package/src/components/annotations/Callout.tsx +0 -139
  134. package/src/components/annotations/MarkerView.tsx +0 -86
  135. package/src/components/annotations/PointAnnotation.tsx +0 -240
  136. /package/ios/components/annotations/{MLRNCallout.h → callout/MLRNCallout.h} +0 -0
  137. /package/ios/components/annotations/{MLRNCallout.m → callout/MLRNCallout.m} +0 -0
@@ -7,7 +7,7 @@ import com.facebook.react.bridge.WritableMap;
7
7
  import com.facebook.react.bridge.WritableNativeMap;
8
8
 
9
9
  import org.maplibre.android.geometry.LatLng;
10
- import org.maplibre.reactnative.components.annotations.MLRNPointAnnotation;
10
+ import org.maplibre.reactnative.components.annotations.pointannotation.MLRNPointAnnotation;
11
11
  import org.maplibre.reactnative.events.constants.EventKeys;
12
12
  import org.maplibre.reactnative.events.constants.EventTypes;
13
13
  import org.maplibre.reactnative.utils.GeoJSONUtils;
@@ -7,7 +7,7 @@ import com.facebook.react.bridge.WritableMap;
7
7
  import com.facebook.react.bridge.WritableNativeMap;
8
8
 
9
9
  import org.maplibre.android.geometry.LatLng;
10
- import org.maplibre.reactnative.components.annotations.MLRNPointAnnotation;
10
+ import org.maplibre.reactnative.components.annotations.pointannotation.MLRNPointAnnotation;
11
11
  import org.maplibre.reactnative.events.constants.EventKeys;
12
12
  import org.maplibre.reactnative.events.constants.EventTypes;
13
13
  import org.maplibre.reactnative.utils.GeoJSONUtils;
@@ -0,0 +1,30 @@
1
+ package org.maplibre.reactnative.events
2
+
3
+ import android.graphics.PointF
4
+ import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.bridge.WritableMap
6
+ import com.facebook.react.uimanager.events.Event
7
+ import org.maplibre.android.geometry.LatLng
8
+ import org.maplibre.reactnative.utils.GeoJSONUtils
9
+
10
+ class PointAnnotationEvent(
11
+ surfaceId: Int,
12
+ viewId: Int,
13
+ private val internalEventName: String,
14
+ private val annotationId: String?,
15
+ private val latLng: LatLng,
16
+ private val screenPoint: PointF,
17
+ ) : Event<PointAnnotationEvent>(surfaceId, viewId) {
18
+ override fun getEventName() = internalEventName
19
+
20
+ override fun getEventData(): WritableMap {
21
+ return Arguments.createMap().apply {
22
+ putString("id", annotationId ?: "")
23
+ putArray("lngLat", GeoJSONUtils.fromLatLng(latLng))
24
+ putArray("point", Arguments.createArray().apply {
25
+ pushDouble(screenPoint.x.toDouble())
26
+ pushDouble(screenPoint.y.toDouble())
27
+ })
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,10 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface MLRNCalloutComponentView : RCTViewComponentView
7
+
8
+ @end
9
+
10
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,91 @@
1
+ #import "MLRNCalloutComponentView.h"
2
+
3
+ #import <react/renderer/components/MapLibreReactNativeSpec/ComponentDescriptors.h>
4
+ #import <react/renderer/components/MapLibreReactNativeSpec/EventEmitters.h>
5
+ #import <react/renderer/components/MapLibreReactNativeSpec/Props.h>
6
+ #import <react/renderer/components/MapLibreReactNativeSpec/RCTComponentViewHelpers.h>
7
+
8
+ #import "RCTFabricComponentsPlugins.h"
9
+
10
+ #import <React/RCTConversions.h>
11
+ #import "MLRNCallout.h"
12
+
13
+ using namespace facebook::react;
14
+
15
+ // MARK: - MLRNCalloutComponentView
16
+
17
+ @interface MLRNCalloutComponentView () <RCTMLRNCalloutViewProtocol>
18
+
19
+ @end
20
+
21
+ @implementation MLRNCalloutComponentView {
22
+ MLRNCallout *_view;
23
+ }
24
+
25
+ + (BOOL)shouldBeRecycled {
26
+ return NO;
27
+ }
28
+
29
+ - (UIView *)contentView {
30
+ // Return _view so PointAnnotation's mountChildComponentView can detect this as a Callout
31
+ // via: [contentView isKindOfClass:[MLRNCallout class]]
32
+ return _view;
33
+ }
34
+
35
+ - (instancetype)initWithFrame:(CGRect)frame {
36
+ if (self = [super initWithFrame:frame]) {
37
+ static const auto defaultProps = std::make_shared<const MLRNCalloutProps>();
38
+ _props = defaultProps;
39
+ [self prepareView];
40
+ }
41
+
42
+ return self;
43
+ }
44
+
45
+ - (void)prepareView {
46
+ _view = [[MLRNCallout alloc] init];
47
+ }
48
+
49
+ #pragma mark - Child Mounting
50
+
51
+ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
52
+ index:(NSInteger)index {
53
+ // Add children to _view (the MLRNCallout) so they're visible when presented
54
+ // This includes the Animated.View with title/content that React renders
55
+ [_view insertSubview:childComponentView atIndex:index];
56
+ }
57
+
58
+ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
59
+ index:(NSInteger)index {
60
+ [childComponentView removeFromSuperview];
61
+ }
62
+
63
+ - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics
64
+ oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics {
65
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
66
+
67
+ // Forward layout to _view so the callout has the correct size
68
+ CGRect frame = CGRectMake(
69
+ layoutMetrics.frame.origin.x,
70
+ layoutMetrics.frame.origin.y,
71
+ layoutMetrics.frame.size.width,
72
+ layoutMetrics.frame.size.height
73
+ );
74
+ _view.frame = frame;
75
+ }
76
+
77
+ #pragma mark - RCTComponentViewProtocol
78
+
79
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
80
+ [super updateProps:props oldProps:oldProps];
81
+ }
82
+
83
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
84
+ return concreteComponentDescriptorProvider<MLRNCalloutComponentDescriptor>();
85
+ }
86
+
87
+ @end
88
+
89
+ Class<RCTComponentViewProtocol> MLRNCalloutCls(void) {
90
+ return MLRNCalloutComponentView.class;
91
+ }
@@ -0,0 +1,44 @@
1
+ #import <React/RCTComponent.h>
2
+ #import <React/RCTView.h>
3
+ #import <UIKit/UIKit.h>
4
+ #import "MLRNCallout.h"
5
+
6
+ #import <MapLibre/MapLibre.h>
7
+
8
+ @interface MLRNPointAnnotation : MLNAnnotationView <MLNAnnotation>
9
+
10
+ @property (nonatomic, weak) MLNMapView *map;
11
+ @property (nonatomic, strong) MLRNCallout *calloutView;
12
+
13
+ @property (nonatomic, copy) NSString *id;
14
+ @property (nonatomic, copy) NSString *reactTitle;
15
+ @property (nonatomic, copy) NSString *reactSnippet;
16
+
17
+ @property (nonatomic, copy) NSArray<NSNumber *> *reactLngLat;
18
+ @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
19
+
20
+ @property (nonatomic, copy) NSDictionary<NSString *, NSNumber *> *anchor;
21
+ @property (nonatomic, copy) NSDictionary<NSString *, NSNumber *> *offset;
22
+
23
+ @property (nonatomic, copy) void (^reactOnSelected)(NSDictionary *event);
24
+ @property (nonatomic, copy) void (^reactOnDeselected)(NSDictionary *event);
25
+ @property (nonatomic, copy) void (^reactOnDragStart)(NSDictionary *event);
26
+ @property (nonatomic, copy) void (^reactOnDrag)(NSDictionary *event);
27
+ @property (nonatomic, copy) void (^reactOnDragEnd)(NSDictionary *event);
28
+
29
+ @property (nonatomic, assign) BOOL reactSelected;
30
+ @property (nonatomic, assign) BOOL reactDraggable;
31
+ @property (nonatomic, assign) BOOL hasExplicitZIndex;
32
+ @property (nonatomic, assign) CGFloat explicitZIndex;
33
+
34
+ // For Fabric: track custom child count without adding to view hierarchy
35
+ @property (nonatomic, assign) NSInteger customChildCount;
36
+
37
+ - (MLNAnnotationView *)getAnnotationView;
38
+ - (NSDictionary *)makeEventPayload;
39
+ - (void)setZIndex:(CGFloat)zIndex;
40
+
41
+ - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex;
42
+ - (void)removeReactSubview:(UIView *)subview;
43
+
44
+ @end
@@ -49,6 +49,11 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
49
49
  [self _setCenterOffset:self.frame];
50
50
  }
51
51
 
52
+ - (void)setOffset:(NSDictionary<NSString *, NSNumber *> *)offset {
53
+ _offset = offset;
54
+ [self _setCenterOffset:self.frame];
55
+ }
56
+
52
57
  - (void)setMap:(MLNMapView *)map {
53
58
  if (map == nil) {
54
59
  [_map removeAnnotation:self];
@@ -83,8 +88,8 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
83
88
  self.draggable = _reactDraggable;
84
89
  }
85
90
 
86
- - (void)setReactCoordinate:(NSString *)reactCoordinate {
87
- _reactCoordinate = reactCoordinate;
91
+ - (void)setReactLngLat:(NSArray<NSNumber *> *)reactLngLat {
92
+ _reactLngLat = reactLngLat;
88
93
  [self _updateCoordinate];
89
94
  }
90
95
 
@@ -104,16 +109,28 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
104
109
  return _reactTitle;
105
110
  }
106
111
 
112
+ - (void)setZIndex:(CGFloat)zIndex {
113
+ _hasExplicitZIndex = YES;
114
+ _explicitZIndex = zIndex;
115
+ self.layer.zPosition = zIndex;
116
+ }
117
+
107
118
  - (MLNAnnotationView *)getAnnotationView {
108
- if (self.reactSubviews.count == 0) {
119
+ // Check both reactSubviews (old arch) and customChildCount (Fabric)
120
+ BOOL hasCustomChildren = (self.reactSubviews.count > 0) || (self.customChildCount > 0);
121
+
122
+ if (!hasCustomChildren) {
109
123
  // default pin view
110
124
  return nil;
111
125
  } else {
112
126
  // custom view
113
127
  self.enabled = YES;
114
- const CGFloat defaultZPosition = 0.0;
115
- if (self.layer.zPosition == defaultZPosition) {
116
- self.layer.zPosition = [self _getZPosition];
128
+ // Only use latitude-based zPosition if no explicit zIndex was set
129
+ if (!_hasExplicitZIndex) {
130
+ const CGFloat defaultZPosition = 0.0;
131
+ if (self.layer.zPosition == defaultZPosition) {
132
+ self.layer.zPosition = [self _getZPosition];
133
+ }
117
134
  }
118
135
  [self addGestureRecognizer:customViewTap];
119
136
  return self;
@@ -130,45 +147,54 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
130
147
  }
131
148
 
132
149
  - (void)_setCenterOffset:(CGRect)frame {
133
- if (frame.size.width == 0 || frame.size.height == 0 || _anchor == nil) {
150
+ if (frame.size.width == 0 || frame.size.height == 0) {
134
151
  return;
135
152
  }
136
153
 
137
- float x = [_anchor[@"x"] floatValue];
138
- float y = [_anchor[@"y"] floatValue];
154
+ float dx = 0;
155
+ float dy = 0;
156
+
157
+ // Apply anchor offset (anchor is a percentage of view dimensions)
158
+ if (_anchor != nil) {
159
+ float x = [_anchor[@"x"] floatValue];
160
+ float y = [_anchor[@"y"] floatValue];
139
161
 
140
- float dx = -(x * frame.size.width - (frame.size.width / 2));
141
- float dy = -(y * frame.size.height - (frame.size.height / 2));
162
+ dx = -(x * frame.size.width - (frame.size.width / 2));
163
+ dy = -(y * frame.size.height - (frame.size.height / 2));
142
164
 
143
- // special cases 0 and 1
165
+ // special cases 0 and 1
166
+ if (x == 0) {
167
+ dx = frame.size.width / 2;
168
+ } else if (x == 1) {
169
+ dx = -frame.size.width / 2;
170
+ }
144
171
 
145
- if (x == 0) {
146
- dx = frame.size.width / 2;
147
- } else if (x == 1) {
148
- dx = -frame.size.width / 2;
172
+ if (y == 0) {
173
+ dy = frame.size.height / 2;
174
+ } else if (y == 1) {
175
+ dy = -frame.size.height / 2;
176
+ }
149
177
  }
150
178
 
151
- if (y == 0) {
152
- dy = frame.size.height / 2;
153
- } else if (y == 1) {
154
- dy = -frame.size.height / 2;
179
+ // Apply pixel offset
180
+ if (_offset != nil) {
181
+ dx += [_offset[@"x"] floatValue];
182
+ dy += [_offset[@"y"] floatValue];
155
183
  }
156
184
 
157
185
  self.centerOffset = CGVectorMake(dx, dy);
158
186
  }
159
187
 
160
188
  - (void)_updateCoordinate {
161
- if (_reactCoordinate == nil) {
189
+ if (_reactLngLat == nil || _reactLngLat.count < 2) {
162
190
  return;
163
191
  }
164
192
 
165
- MLNPointFeature *feature = (MLNPointFeature *)[MLRNUtils shapeFromGeoJSON:_reactCoordinate];
166
- if (feature == nil) {
167
- return;
168
- }
193
+ double lng = [_reactLngLat[0] doubleValue];
194
+ double lat = [_reactLngLat[1] doubleValue];
169
195
 
170
196
  dispatch_async(dispatch_get_main_queue(), ^{
171
- self.coordinate = feature.coordinate;
197
+ self.coordinate = CLLocationCoordinate2DMake(lat, lng);
172
198
  });
173
199
  }
174
200
 
@@ -187,29 +213,37 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
187
213
  return self.frame.size.width > 0 && self.frame.size.height > 0;
188
214
  }
189
215
 
216
+ - (NSDictionary *)makeEventPayload {
217
+ NSMutableDictionary *payload = [NSMutableDictionary dictionary];
218
+ payload[@"id"] = _id ?: @"";
219
+ payload[@"lngLat"] = @[@(self.coordinate.longitude), @(self.coordinate.latitude)];
220
+
221
+ CGPoint screenPoint = [_map convertCoordinate:self.coordinate toPointToView:_map];
222
+ payload[@"point"] = @[@(screenPoint.x), @(screenPoint.y)];
223
+
224
+ return payload;
225
+ }
226
+
190
227
  - (void)setDragState:(MLNAnnotationViewDragState)dragState animated:(BOOL)animated {
191
228
  [super setDragState:dragState animated:animated];
192
229
  switch (dragState) {
193
230
  case MLNAnnotationViewDragStateStarting: {
194
- if (self.onDragStart != nil) {
195
- MLRNMapTouchEvent *event = [MLRNMapTouchEvent makeAnnotationTapEvent:self];
196
- self.onDragStart([event toJSON]);
231
+ if (self.reactOnDragStart != nil) {
232
+ self.reactOnDragStart([self makeEventPayload]);
197
233
  }
198
234
  break;
199
235
  }
200
236
 
201
237
  case MLNAnnotationViewDragStateDragging:
202
- if (self.onDrag != nil) {
203
- MLRNMapTouchEvent *event = [MLRNMapTouchEvent makeAnnotationTapEventOnDrag:self];
204
- self.onDrag([event toJSON]);
238
+ if (self.reactOnDrag != nil) {
239
+ self.reactOnDrag([self makeEventPayload]);
205
240
  }
206
241
  break;
207
242
 
208
243
  case MLNAnnotationViewDragStateEnding:
209
244
  case MLNAnnotationViewDragStateCanceling: {
210
- if (self.onDragEnd != nil) {
211
- MLRNMapTouchEvent *event = [MLRNMapTouchEvent makeAnnotationTapEvent:self];
212
- self.onDragEnd([event toJSON]);
245
+ if (self.reactOnDragEnd != nil) {
246
+ self.reactOnDragEnd([self makeEventPayload]);
213
247
  }
214
248
  break;
215
249
  }
@@ -0,0 +1,10 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface MLRNPointAnnotationComponentView : RCTViewComponentView
7
+
8
+ @end
9
+
10
+ NS_ASSUME_NONNULL_END