@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
@@ -1,240 +0,0 @@
1
- import { point } from "@turf/helpers";
2
- import {
3
- Component,
4
- type SyntheticEvent,
5
- forwardRef,
6
- useImperativeHandle,
7
- useRef,
8
- type ReactElement,
9
- } from "react";
10
- import {
11
- Platform,
12
- StyleSheet,
13
- type ViewProps,
14
- requireNativeComponent,
15
- } from "react-native";
16
-
17
- import { useNativeBridge, type RNMLEvent } from "../../hooks/useNativeBridge";
18
- import { isFunction, toJSONString } from "../../utils";
19
-
20
- export const NATIVE_MODULE_NAME = "MLRNPointAnnotation";
21
-
22
- const styles = StyleSheet.create({
23
- container: {
24
- alignItems: "center",
25
- justifyContent: "center",
26
- position: "absolute",
27
- },
28
- });
29
-
30
- type FeaturePayload = GeoJSON.Feature<
31
- GeoJSON.Point,
32
- {
33
- screenPointX: number;
34
- screenPointY: number;
35
- }
36
- >;
37
-
38
- export interface PointAnnotationProps {
39
- /**
40
- * A string that uniquely identifies the annotation
41
- */
42
- id: string;
43
- /**
44
- * The string containing the annotation’s title. Note this is required to be set if you want to see a callout appear on iOS.
45
- */
46
- title?: string;
47
- /**
48
- * The string containing the annotation’s snippet(subtitle). Not displayed in the default callout.
49
- */
50
- snippet?: string;
51
- /**
52
- * Manually selects/deselects annotation
53
- */
54
- selected?: boolean;
55
- /**
56
- * Enable or disable dragging. Defaults to false.
57
- */
58
- draggable?: boolean;
59
- /**
60
- * The center point (specified as a map coordinate) of the annotation.
61
- */
62
- coordinate: number[];
63
- /**
64
- * Specifies the anchor being set on a particular point of the annotation.
65
- * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],
66
- * where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.
67
- * Note this is only for custom annotations not the default pin view.
68
- * Defaults to the center of the view.
69
- */
70
- anchor?: {
71
- /**
72
- * See anchor
73
- */
74
- x: number;
75
- /**
76
- * See anchor
77
- */
78
- y: number;
79
- };
80
- /**
81
- * This callback is fired once this annotation is selected. Returns a Feature as the first param.
82
- */
83
- onSelected?: (payload: FeaturePayload) => void;
84
- /**
85
- * This callback is fired once this annotation is deselected.
86
- */
87
- onDeselected?: (payload: FeaturePayload) => void;
88
- /**
89
- * This callback is fired once this annotation has started being dragged.
90
- */
91
- onDragStart?: (payload: FeaturePayload) => void;
92
- /**
93
- * This callback is fired once this annotation has stopped being dragged.
94
- */
95
- onDragEnd?: (payload: FeaturePayload) => void;
96
- /**
97
- * This callback is fired while this annotation is being dragged.
98
- */
99
- onDrag?: (payload: FeaturePayload) => void;
100
-
101
- /**
102
- * Expects one child, and an optional callout can be added as well
103
- */
104
- children: ReactElement | [ReactElement, ReactElement];
105
-
106
- style?: ViewProps["style"];
107
- }
108
-
109
- interface NativeProps extends Omit<PointAnnotationProps, "coordinate"> {
110
- coordinate?: string;
111
- }
112
-
113
- export interface PointAnnotationRef {
114
- refresh(): void;
115
- }
116
-
117
- /**
118
- * PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
119
- *
120
- * Consider using GeoJSONSource and SymbolLayer instead, if you have many points, and you have static images,
121
- * they'll offer much better performance.
122
- *
123
- * If you need interactive views please use MarkerView,
124
- * as with PointAnnotation on Android child views are rendered onto a bitmap for better performance.
125
- */
126
- export const PointAnnotation = forwardRef<
127
- PointAnnotationRef,
128
- PointAnnotationProps
129
- >(
130
- (
131
- {
132
- anchor = { x: 0.5, y: 0.5 },
133
- draggable = false,
134
- ...props
135
- }: PointAnnotationProps,
136
- ref,
137
- ) => {
138
- useImperativeHandle(
139
- ref,
140
- (): PointAnnotationRef => ({
141
- /**
142
- * On android point annotation is rendered offscreen with a canvas into an image.
143
- * To rerender the image from the current state of the view call refresh.
144
- * Call this for example from Image#onLoad.
145
- */
146
- refresh,
147
- }),
148
- );
149
-
150
- const { _runNativeCommand, _runPendingNativeCommands } =
151
- useNativeBridge(NATIVE_MODULE_NAME);
152
- const _nativeRef = useRef<Component<NativeProps>>(null);
153
-
154
- function refresh(): void {
155
- if (Platform.OS === "android") {
156
- _runNativeCommand("refresh", _nativeRef.current, []);
157
- }
158
- }
159
-
160
- function _onSelected(
161
- e: SyntheticEvent<Element, RNMLEvent<FeaturePayload>>,
162
- ): void {
163
- if (isFunction(props.onSelected)) {
164
- props.onSelected(e.nativeEvent.payload);
165
- }
166
- }
167
-
168
- function _onDeselected(
169
- e: SyntheticEvent<Element, RNMLEvent<FeaturePayload>>,
170
- ): void {
171
- if (isFunction(props.onDeselected)) {
172
- props.onDeselected(e.nativeEvent.payload);
173
- }
174
- }
175
-
176
- function _onDragStart(
177
- e: SyntheticEvent<Element, RNMLEvent<FeaturePayload>>,
178
- ): void {
179
- if (isFunction(props.onDragStart)) {
180
- props.onDragStart(e.nativeEvent.payload);
181
- }
182
- }
183
-
184
- function _onDrag(
185
- e: SyntheticEvent<Element, RNMLEvent<FeaturePayload>>,
186
- ): void {
187
- if (isFunction(props.onDrag)) {
188
- props.onDrag(e.nativeEvent.payload);
189
- }
190
- }
191
-
192
- function _onDragEnd(
193
- e: SyntheticEvent<Element, RNMLEvent<FeaturePayload>>,
194
- ): void {
195
- if (isFunction(props.onDragEnd)) {
196
- props.onDragEnd(e.nativeEvent.payload);
197
- }
198
- }
199
-
200
- function _getCoordinate(): string | undefined {
201
- if (!props.coordinate) {
202
- return undefined;
203
- }
204
- return toJSONString(point(props.coordinate));
205
- }
206
-
207
- const _setNativeRef = (nativeRef: Component<NativeProps> | null): void => {
208
- _nativeRef.current = nativeRef;
209
- _runPendingNativeCommands(nativeRef);
210
- };
211
-
212
- const nativeProps = {
213
- ...props,
214
- anchor,
215
- draggable,
216
- ref: (nativeRef: Component<NativeProps> | null) =>
217
- _setNativeRef(nativeRef),
218
- id: props.id,
219
- title: props.title,
220
- snippet: props.snippet,
221
- selected: props.selected,
222
- style: [props.style, styles.container],
223
- onMapboxPointAnnotationSelected: _onSelected,
224
- onMapboxPointAnnotationDeselected: _onDeselected,
225
- onMapboxPointAnnotationDragStart: _onDragStart,
226
- onMapboxPointAnnotationDrag: _onDrag,
227
- onMapboxPointAnnotationDragEnd: _onDragEnd,
228
- coordinate: _getCoordinate(),
229
- };
230
-
231
- return (
232
- <MLRNPointAnnotation {...nativeProps}>
233
- {props.children}
234
- </MLRNPointAnnotation>
235
- );
236
- },
237
- );
238
-
239
- const MLRNPointAnnotation =
240
- requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);