@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.
- package/android/build.gradle +1 -3
- package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +3 -3
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/callout/MLRNCallout.kt +7 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/callout/MLRNCalloutManager.kt +29 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerView.kt +220 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerViewContent.kt +50 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerViewManager.kt +81 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MarkerViewManager.kt +127 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/pointannotation/MLRNPointAnnotation.kt +407 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/pointannotation/MLRNPointAnnotationManager.kt +105 -0
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +38 -37
- package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationClickEvent.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationDragEvent.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationEvent.kt +30 -0
- package/ios/components/annotations/callout/MLRNCalloutComponentView.h +10 -0
- package/ios/components/annotations/callout/MLRNCalloutComponentView.mm +91 -0
- package/ios/components/annotations/point-annotation/MLRNPointAnnotation.h +44 -0
- package/ios/components/annotations/{MLRNPointAnnotation.m → point-annotation/MLRNPointAnnotation.m} +69 -35
- package/ios/components/annotations/point-annotation/MLRNPointAnnotationComponentView.h +10 -0
- package/ios/components/annotations/point-annotation/MLRNPointAnnotationComponentView.mm +331 -0
- package/ios/components/map-view/MLRNMapView.m +4 -5
- package/lib/commonjs/components/annotations/callout/Callout.js +94 -0
- package/lib/commonjs/components/annotations/callout/Callout.js.map +1 -0
- package/lib/commonjs/components/annotations/callout/CalloutNativeComponent.ts +11 -0
- package/lib/commonjs/components/annotations/marker-view/MarkerView.js +70 -0
- package/lib/commonjs/components/annotations/marker-view/MarkerView.js.map +1 -0
- package/lib/commonjs/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
- package/lib/commonjs/components/annotations/point-annotation/PointAnnotation.js +88 -0
- package/lib/commonjs/components/annotations/point-annotation/PointAnnotation.js.map +1 -0
- package/lib/commonjs/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
- package/lib/commonjs/index.js +3 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/Anchor.js +68 -0
- package/lib/commonjs/types/Anchor.js.map +1 -0
- package/lib/commonjs/utils/animated/Animated.js +4 -0
- package/lib/commonjs/utils/animated/Animated.js.map +1 -1
- package/lib/module/components/annotations/callout/Callout.js +88 -0
- package/lib/module/components/annotations/callout/Callout.js.map +1 -0
- package/lib/module/components/annotations/callout/CalloutNativeComponent.ts +11 -0
- package/lib/module/components/annotations/marker-view/MarkerView.js +64 -0
- package/lib/module/components/annotations/marker-view/MarkerView.js.map +1 -0
- package/lib/module/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
- package/lib/module/components/annotations/point-annotation/PointAnnotation.js +83 -0
- package/lib/module/components/annotations/point-annotation/PointAnnotation.js.map +1 -0
- package/lib/module/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/Anchor.js +64 -0
- package/lib/module/types/Anchor.js.map +1 -0
- package/lib/module/utils/animated/Animated.js +4 -0
- package/lib/module/utils/animated/Animated.js.map +1 -1
- package/lib/typescript/{module/src/components/annotations → commonjs/src/components/annotations/callout}/Callout.d.ts +9 -9
- package/lib/typescript/commonjs/src/components/annotations/callout/Callout.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/annotations/callout/CalloutNativeComponent.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/annotations/callout/CalloutNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerView.d.ts +52 -0
- package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts +21 -0
- package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotation.d.ts +95 -0
- package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts +43 -0
- package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -4
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/Anchor.d.ts +17 -0
- package/lib/typescript/commonjs/src/types/Anchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +1 -0
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
- package/lib/typescript/{commonjs/src/components/annotations → module/src/components/annotations/callout}/Callout.d.ts +9 -9
- package/lib/typescript/module/src/components/annotations/callout/Callout.d.ts.map +1 -0
- package/lib/typescript/module/src/components/annotations/callout/CalloutNativeComponent.d.ts +6 -0
- package/lib/typescript/module/src/components/annotations/callout/CalloutNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/annotations/marker-view/MarkerView.d.ts +52 -0
- package/lib/typescript/module/src/components/annotations/marker-view/MarkerView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts +21 -0
- package/lib/typescript/module/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotation.d.ts +95 -0
- package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotation.d.ts.map +1 -0
- package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts +43 -0
- package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -4
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types/Anchor.d.ts +17 -0
- package/lib/typescript/module/src/types/Anchor.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/Animated.d.ts +1 -0
- package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/components/annotations/callout/Callout.tsx +145 -0
- package/src/components/annotations/callout/CalloutNativeComponent.ts +11 -0
- package/src/components/annotations/marker-view/MarkerView.tsx +124 -0
- package/src/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
- package/src/components/annotations/point-annotation/PointAnnotation.tsx +219 -0
- package/src/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
- package/src/index.ts +15 -4
- package/src/types/Anchor.ts +44 -0
- package/src/utils/animated/Animated.tsx +6 -0
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNCallout.java +0 -11
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNCalloutManager.java +0 -18
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNMarkerView.java +0 -112
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNMarkerViewManager.java +0 -45
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNPointAnnotation.java +0 -361
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNPointAnnotationManager.java +0 -84
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MarkerView.java +0 -23
- package/android/src/main/java/org/maplibre/reactnative/components/annotations/MarkerViewManager.java +0 -69
- package/ios/components/annotations/MLRNCalloutManager.h +0 -5
- package/ios/components/annotations/MLRNCalloutManager.m +0 -12
- package/ios/components/annotations/MLRNPointAnnotation.h +0 -33
- package/ios/components/annotations/MLRNPointAnnotationManager.h +0 -5
- package/ios/components/annotations/MLRNPointAnnotationManager.m +0 -27
- package/lib/commonjs/components/annotations/Callout.js +0 -101
- package/lib/commonjs/components/annotations/Callout.js.map +0 -1
- package/lib/commonjs/components/annotations/MarkerView.js +0 -60
- package/lib/commonjs/components/annotations/MarkerView.js.map +0 -1
- package/lib/commonjs/components/annotations/PointAnnotation.js +0 -114
- package/lib/commonjs/components/annotations/PointAnnotation.js.map +0 -1
- package/lib/module/components/annotations/Callout.js +0 -96
- package/lib/module/components/annotations/Callout.js.map +0 -1
- package/lib/module/components/annotations/MarkerView.js +0 -55
- package/lib/module/components/annotations/MarkerView.js.map +0 -1
- package/lib/module/components/annotations/PointAnnotation.js +0 -110
- package/lib/module/components/annotations/PointAnnotation.js.map +0 -1
- package/lib/typescript/commonjs/src/components/annotations/Callout.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/annotations/MarkerView.d.ts +0 -44
- package/lib/typescript/commonjs/src/components/annotations/MarkerView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts +0 -90
- package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts.map +0 -1
- package/lib/typescript/module/src/components/annotations/Callout.d.ts.map +0 -1
- package/lib/typescript/module/src/components/annotations/MarkerView.d.ts +0 -44
- package/lib/typescript/module/src/components/annotations/MarkerView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts +0 -90
- package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts.map +0 -1
- package/src/components/annotations/Callout.tsx +0 -139
- package/src/components/annotations/MarkerView.tsx +0 -86
- package/src/components/annotations/PointAnnotation.tsx +0 -240
- /package/ios/components/annotations/{MLRNCallout.h → callout/MLRNCallout.h} +0 -0
- /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);
|
|
File without changes
|
|
File without changes
|