@maplibre/maplibre-react-native 10.0.0-alpha.21 → 10.0.0-alpha.23
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/.eslintrc.js +5 -0
- package/.git-blame-ignore-revs +3 -0
- package/CHANGELOG.md +21 -0
- package/CONTRIBUTING.md +20 -14
- package/README.md +12 -13
- package/android/install.md +3 -2
- package/app.plugin.js +1 -1
- package/babel.config.js +6 -3
- package/docs/Camera.md +1 -1
- package/docs/GettingStarted.md +3 -4
- package/docs/MapView.md +1 -1
- package/docs/ShapeSource.md +3 -3
- package/docs/docs.json +15 -15
- package/ios/RCTMLN.xcodeproj/project.pbxproj +1 -775
- package/ios/install.md +1 -1
- package/javascript/components/Camera.tsx +8 -8
- package/javascript/components/MapView.tsx +4 -6
- package/javascript/components/MarkerView.tsx +2 -2
- package/javascript/components/PointAnnotation.tsx +2 -2
- package/javascript/components/ShapeSource.tsx +29 -28
- package/javascript/components/Style.tsx +1 -1
- package/javascript/modules/offline/OfflineCreatePackOptions.ts +2 -9
- package/javascript/modules/snapshot/SnapshotOptions.ts +4 -5
- package/javascript/utils/StyleValue.ts +3 -1
- package/javascript/utils/makeNativeBounds.ts +5 -0
- package/jest-setup.ts +113 -0
- package/jest.config.js +8 -0
- package/maplibre-react-native.podspec +7 -7
- package/package.json +30 -73
- package/plugin/build/withMapLibre.js +16 -1
- package/plugin/install.md +1 -8
- package/react-native.config.js +1 -1
- package/scripts/.eslintrc.js +3 -0
- package/scripts/{autogenerate.js → generate-docs.js} +144 -137
- package/scripts/templates/MaplibreStyles.ts.ejs +5 -5
- package/scripts/templates/RCTMLNStyle.h.ejs +2 -2
- package/scripts/templates/RCTMLNStyle.m.ejs +6 -6
- package/scripts/templates/RCTMLNStyleFactory.java.ejs +8 -8
- package/scripts/{autogenHelpers → utils}/DocJSONBuilder.js +70 -70
- package/scripts/{autogenHelpers → utils}/JSDocNodeTree.js +33 -30
- package/scripts/utils/MarkdownBuilder.js +37 -0
- package/scripts/utils/template-globals.js +528 -0
- package/style-spec/v8.json +32 -1
- package/tsconfig.json +2 -2
- package/assets/mapbox_logo.png +0 -0
- package/javascript/utils/geoUtils.ts +0 -79
- package/scripts/autogenHelpers/MarkdownBuilder.js +0 -29
- package/scripts/autogenHelpers/globals.js +0 -508
- package/setup-jest.js +0 -108
package/ios/install.md
CHANGED
|
@@ -26,7 +26,7 @@ You are good to go!
|
|
|
26
26
|
|
|
27
27
|
## Note on iOS Simulator issues
|
|
28
28
|
|
|
29
|
-
MapLibre
|
|
29
|
+
MapLibre Native has some issues on iOS Simulators in many
|
|
30
30
|
environments. The map either does not render at all or appears garbled when panning and zooming.
|
|
31
31
|
It is best to test on a real device if at all possible at this time
|
|
32
32
|
until this is fixed upstream. iOS devs can open the workspace in Xcode and run from there.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import { point } from "@turf/helpers";
|
|
1
2
|
import React, {
|
|
2
3
|
memo,
|
|
3
4
|
RefObject,
|
|
5
|
+
useCallback,
|
|
4
6
|
useEffect,
|
|
5
7
|
useImperativeHandle,
|
|
6
8
|
useMemo,
|
|
7
9
|
useRef,
|
|
8
|
-
useCallback,
|
|
9
10
|
} from "react";
|
|
10
11
|
import { NativeModules, requireNativeComponent, ViewProps } from "react-native";
|
|
11
12
|
|
|
12
13
|
import { useNativeRef } from "../hooks/useNativeRef";
|
|
13
14
|
import { MaplibreGLEvent } from "../types";
|
|
14
|
-
import {
|
|
15
|
-
import * as geoUtils from "../utils/geoUtils";
|
|
15
|
+
import { makeNativeBounds } from "../utils/makeNativeBounds";
|
|
16
16
|
|
|
17
17
|
const MapLibreGL = NativeModules.MLNModule;
|
|
18
18
|
|
|
@@ -165,7 +165,7 @@ interface CameraProps extends Omit<ViewProps, "style">, CameraStop {
|
|
|
165
165
|
followUserLocation?: boolean;
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
* The mode used to track the user location on the map. One of; "normal", "compass", "course". Each mode string is also available as a member on the `MapLibreGL.UserTrackingModes` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](
|
|
168
|
+
* The mode used to track the user location on the map. One of; "normal", "compass", "course". Each mode string is also available as a member on the `MapLibreGL.UserTrackingModes` object. `Follow` (normal), `FollowWithHeading` (compass), `FollowWithCourse` (course). NOTE: `followUserLocation` must be set to `true` for any of the modes to take effect. [Example](/packages/examples/src/examples/Camera/SetUserTrackingModes.js)
|
|
169
169
|
*/
|
|
170
170
|
followUserMode?: UserTrackingMode;
|
|
171
171
|
|
|
@@ -334,14 +334,14 @@ const Camera = memo(
|
|
|
334
334
|
};
|
|
335
335
|
|
|
336
336
|
if (config.centerCoordinate) {
|
|
337
|
-
stopConfig.centerCoordinate =
|
|
338
|
-
|
|
337
|
+
stopConfig.centerCoordinate = JSON.stringify(
|
|
338
|
+
point(config.centerCoordinate),
|
|
339
339
|
);
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
if (config.bounds && config.bounds.ne && config.bounds.sw) {
|
|
343
343
|
const { ne, sw } = config.bounds;
|
|
344
|
-
stopConfig.bounds =
|
|
344
|
+
stopConfig.bounds = makeNativeBounds(ne, sw);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
return stopConfig;
|
|
@@ -377,7 +377,7 @@ const Camera = memo(
|
|
|
377
377
|
if (!bounds || !bounds.ne || !bounds.sw) {
|
|
378
378
|
return null;
|
|
379
379
|
}
|
|
380
|
-
return
|
|
380
|
+
return makeNativeBounds(bounds.ne, bounds.sw);
|
|
381
381
|
}, [props.maxBounds]);
|
|
382
382
|
|
|
383
383
|
useEffect(() => {
|
|
@@ -33,7 +33,7 @@ import { getFilter } from "../utils/filterUtils";
|
|
|
33
33
|
const MapLibreGL = NativeModules.MLNModule;
|
|
34
34
|
if (MapLibreGL == null) {
|
|
35
35
|
console.error(
|
|
36
|
-
"Native
|
|
36
|
+
"Native module of @maplibre/maplibre-react-native library was not registered properly, please consult the docs: https://github.com/maplibre/maplibre-react-native",
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -281,9 +281,8 @@ export interface MapViewRef {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
|
-
* MapView backed by MapLibre
|
|
284
|
+
* MapView backed by MapLibre Native
|
|
285
285
|
*/
|
|
286
|
-
|
|
287
286
|
const MapView = memo(
|
|
288
287
|
React.forwardRef<MapViewRef, MapViewProps>(
|
|
289
288
|
(
|
|
@@ -760,7 +759,7 @@ const MapView = memo(
|
|
|
760
759
|
};
|
|
761
760
|
|
|
762
761
|
const contentInsetValue = useMemo(() => {
|
|
763
|
-
if (
|
|
762
|
+
if (props.contentInset === undefined) {
|
|
764
763
|
return;
|
|
765
764
|
}
|
|
766
765
|
|
|
@@ -812,7 +811,7 @@ const MapView = memo(
|
|
|
812
811
|
surfaceView,
|
|
813
812
|
regionWillChangeDebounceTime,
|
|
814
813
|
regionDidChangeDebounceTime,
|
|
815
|
-
contentInsetValue,
|
|
814
|
+
contentInset: contentInsetValue,
|
|
816
815
|
style: styles.matchParent,
|
|
817
816
|
};
|
|
818
817
|
}, [
|
|
@@ -825,7 +824,6 @@ const MapView = memo(
|
|
|
825
824
|
surfaceView,
|
|
826
825
|
regionWillChangeDebounceTime,
|
|
827
826
|
regionDidChangeDebounceTime,
|
|
828
|
-
contentInsetValue,
|
|
829
827
|
props,
|
|
830
828
|
contentInsetValue,
|
|
831
829
|
]);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { point } from "@turf/helpers";
|
|
1
2
|
import React, { ReactElement, useMemo } from "react";
|
|
2
3
|
import { Platform, requireNativeComponent, ViewProps } from "react-native";
|
|
3
4
|
|
|
4
5
|
import PointAnnotation from "./PointAnnotation";
|
|
5
6
|
import { toJSONString } from "../utils";
|
|
6
|
-
import { makePoint } from "../utils/geoUtils";
|
|
7
7
|
|
|
8
8
|
export const NATIVE_MODULE_NAME = "RCTMLNMarkerView";
|
|
9
9
|
|
|
@@ -61,7 +61,7 @@ const MarkerView = ({
|
|
|
61
61
|
}: MarkerViewProps): ReactElement => {
|
|
62
62
|
const props = { anchor, allowOverlap, isSelected, ...rest };
|
|
63
63
|
const coordinate = props.coordinate
|
|
64
|
-
? toJSONString(
|
|
64
|
+
? toJSONString(point(props.coordinate))
|
|
65
65
|
: undefined;
|
|
66
66
|
|
|
67
67
|
const idForPointAnnotation = useMemo(() => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { point } from "@turf/helpers";
|
|
1
2
|
import React, {
|
|
2
3
|
Component,
|
|
3
4
|
SyntheticEvent,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
|
|
16
17
|
import useNativeBridge, { RNMLEvent } from "../hooks/useNativeBridge";
|
|
17
18
|
import { isFunction, toJSONString } from "../utils";
|
|
18
|
-
import { makePoint } from "../utils/geoUtils";
|
|
19
19
|
|
|
20
20
|
export const NATIVE_MODULE_NAME = "RCTMLNPointAnnotation";
|
|
21
21
|
|
|
@@ -200,7 +200,7 @@ const PointAnnotation = forwardRef<PointAnnotationRef, PointAnnotationProps>(
|
|
|
200
200
|
if (!props.coordinate) {
|
|
201
201
|
return undefined;
|
|
202
202
|
}
|
|
203
|
-
return toJSONString(
|
|
203
|
+
return toJSONString(point(props.coordinate));
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
const _setNativeRef = (nativeRef: Component<NativeProps> | null): void => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Feature, FeatureCollection } from "@turf/helpers";
|
|
2
1
|
import React, {
|
|
3
2
|
Component,
|
|
4
3
|
ReactElement,
|
|
@@ -137,14 +136,16 @@ export interface ShapeSourceProps extends BaseProps {
|
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
export interface ShapeSourceRef {
|
|
140
|
-
features(filter?: FilterExpression): Promise<FeatureCollection>;
|
|
141
|
-
getClusterExpansionZoom(feature: Feature): Promise<number>;
|
|
139
|
+
features(filter?: FilterExpression): Promise<GeoJSON.FeatureCollection>;
|
|
140
|
+
getClusterExpansionZoom(feature: GeoJSON.Feature): Promise<number>;
|
|
142
141
|
getClusterLeaves(
|
|
143
|
-
feature: Feature,
|
|
142
|
+
feature: GeoJSON.Feature,
|
|
144
143
|
limit: number,
|
|
145
144
|
offset: number,
|
|
146
|
-
): Promise<FeatureCollection>;
|
|
147
|
-
getClusterChildren(
|
|
145
|
+
): Promise<GeoJSON.FeatureCollection>;
|
|
146
|
+
getClusterChildren(
|
|
147
|
+
feature: GeoJSON.Feature,
|
|
148
|
+
): Promise<GeoJSON.FeatureCollection>;
|
|
148
149
|
setNativeProps: (props: NativeProps) => void;
|
|
149
150
|
onPress: (event: NativeSyntheticEvent<{ payload: OnPressEvent }>) => void;
|
|
150
151
|
|
|
@@ -176,7 +177,7 @@ const ShapeSource = memo(
|
|
|
176
177
|
* shapeSource.features()
|
|
177
178
|
*
|
|
178
179
|
* @param {Array=} filter - an optional filter statement to filter the returned Features.
|
|
179
|
-
* @return {FeatureCollection}
|
|
180
|
+
* @return {GeoJSON.FeatureCollection}
|
|
180
181
|
*/
|
|
181
182
|
features,
|
|
182
183
|
/**
|
|
@@ -185,7 +186,7 @@ const ShapeSource = memo(
|
|
|
185
186
|
* @example
|
|
186
187
|
* const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
|
|
187
188
|
*
|
|
188
|
-
* @param {Feature} feature - The feature cluster to expand.
|
|
189
|
+
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
189
190
|
* @return {number}
|
|
190
191
|
*/
|
|
191
192
|
getClusterExpansionZoom,
|
|
@@ -195,10 +196,10 @@ const ShapeSource = memo(
|
|
|
195
196
|
* @example
|
|
196
197
|
* const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
|
|
197
198
|
*
|
|
198
|
-
* @param {Feature} feature - The feature cluster to expand.
|
|
199
|
+
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
199
200
|
* @param {number} limit - The number of points to return.
|
|
200
201
|
* @param {number} offset - The amount of points to skip (for pagination).
|
|
201
|
-
* @return {FeatureCollection}
|
|
202
|
+
* @return {GeoJSON.FeatureCollection}
|
|
202
203
|
*/
|
|
203
204
|
getClusterLeaves,
|
|
204
205
|
/**
|
|
@@ -207,8 +208,8 @@ const ShapeSource = memo(
|
|
|
207
208
|
* @example
|
|
208
209
|
* const collection = await shapeSource.getClusterChildren(clusterId);
|
|
209
210
|
*
|
|
210
|
-
* @param {Feature} feature - The feature cluster to expand.
|
|
211
|
-
* @return {FeatureCollection}
|
|
211
|
+
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
212
|
+
* @return {GeoJSON.FeatureCollection}
|
|
212
213
|
*/
|
|
213
214
|
getClusterChildren,
|
|
214
215
|
setNativeProps,
|
|
@@ -232,8 +233,8 @@ const ShapeSource = memo(
|
|
|
232
233
|
|
|
233
234
|
async function features(
|
|
234
235
|
filter?: FilterExpression,
|
|
235
|
-
): Promise<FeatureCollection> {
|
|
236
|
-
const res: { data: string | FeatureCollection } =
|
|
236
|
+
): Promise<GeoJSON.FeatureCollection> {
|
|
237
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
237
238
|
await _runNativeCommand("features", _nativeRef.current, [
|
|
238
239
|
getFilter(filter),
|
|
239
240
|
]);
|
|
@@ -242,11 +243,11 @@ const ShapeSource = memo(
|
|
|
242
243
|
return JSON.parse(res.data as string);
|
|
243
244
|
}
|
|
244
245
|
|
|
245
|
-
return res.data as FeatureCollection;
|
|
246
|
+
return res.data as GeoJSON.FeatureCollection;
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
async function getClusterExpansionZoom(
|
|
249
|
-
feature: Feature,
|
|
250
|
+
feature: GeoJSON.Feature,
|
|
250
251
|
): Promise<number> {
|
|
251
252
|
if (typeof feature === "number") {
|
|
252
253
|
console.warn(
|
|
@@ -269,15 +270,15 @@ const ShapeSource = memo(
|
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
async function getClusterLeaves(
|
|
272
|
-
feature: Feature,
|
|
273
|
+
feature: GeoJSON.Feature,
|
|
273
274
|
limit: number,
|
|
274
275
|
offset: number,
|
|
275
|
-
): Promise<FeatureCollection> {
|
|
276
|
+
): Promise<GeoJSON.FeatureCollection> {
|
|
276
277
|
if (typeof feature === "number") {
|
|
277
278
|
console.warn(
|
|
278
279
|
"Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
|
|
279
280
|
);
|
|
280
|
-
const res: { data: string | FeatureCollection } =
|
|
281
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
281
282
|
await _runNativeCommand(
|
|
282
283
|
"getClusterLeavesById",
|
|
283
284
|
_nativeRef.current,
|
|
@@ -288,10 +289,10 @@ const ShapeSource = memo(
|
|
|
288
289
|
return JSON.parse(res.data as string);
|
|
289
290
|
}
|
|
290
291
|
|
|
291
|
-
return res.data as FeatureCollection;
|
|
292
|
+
return res.data as GeoJSON.FeatureCollection;
|
|
292
293
|
}
|
|
293
294
|
|
|
294
|
-
const res: { data: string | FeatureCollection } =
|
|
295
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
295
296
|
await _runNativeCommand("getClusterLeaves", _nativeRef.current, [
|
|
296
297
|
JSON.stringify(feature),
|
|
297
298
|
limit,
|
|
@@ -302,17 +303,17 @@ const ShapeSource = memo(
|
|
|
302
303
|
return JSON.parse(res.data as string);
|
|
303
304
|
}
|
|
304
305
|
|
|
305
|
-
return res.data as FeatureCollection;
|
|
306
|
+
return res.data as GeoJSON.FeatureCollection;
|
|
306
307
|
}
|
|
307
308
|
|
|
308
309
|
async function getClusterChildren(
|
|
309
|
-
feature: Feature,
|
|
310
|
-
): Promise<FeatureCollection> {
|
|
310
|
+
feature: GeoJSON.Feature,
|
|
311
|
+
): Promise<GeoJSON.FeatureCollection> {
|
|
311
312
|
if (typeof feature === "number") {
|
|
312
313
|
console.warn(
|
|
313
314
|
"Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
|
|
314
315
|
);
|
|
315
|
-
const res: { data: string | FeatureCollection } =
|
|
316
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
316
317
|
await _runNativeCommand(
|
|
317
318
|
"getClusterChildrenById",
|
|
318
319
|
_nativeRef.current,
|
|
@@ -323,10 +324,10 @@ const ShapeSource = memo(
|
|
|
323
324
|
return JSON.parse(res.data as string);
|
|
324
325
|
}
|
|
325
326
|
|
|
326
|
-
return res.data as FeatureCollection;
|
|
327
|
+
return res.data as GeoJSON.FeatureCollection;
|
|
327
328
|
}
|
|
328
329
|
|
|
329
|
-
const res: { data: string | FeatureCollection } =
|
|
330
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
330
331
|
await _runNativeCommand("getClusterChildren", _nativeRef.current, [
|
|
331
332
|
JSON.stringify(feature),
|
|
332
333
|
]);
|
|
@@ -335,7 +336,7 @@ const ShapeSource = memo(
|
|
|
335
336
|
return JSON.parse(res.data as string);
|
|
336
337
|
}
|
|
337
338
|
|
|
338
|
-
return res.data as FeatureCollection;
|
|
339
|
+
return res.data as GeoJSON.FeatureCollection;
|
|
339
340
|
}
|
|
340
341
|
|
|
341
342
|
function setNativeProps(nativeProps: NativeProps): void {
|
|
@@ -281,7 +281,7 @@ function asSourceComponent(
|
|
|
281
281
|
return getShapeSource(id, source);
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
console.warn(`
|
|
284
|
+
console.warn(`MapLibre source type '${source.type}' is not supported`);
|
|
285
285
|
|
|
286
286
|
return null;
|
|
287
287
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { makeLatLngBounds } from "../../utils/geoUtils";
|
|
1
|
+
import { makeNativeBounds } from "../../utils/makeNativeBounds";
|
|
3
2
|
|
|
4
3
|
export interface OfflineCreatePackInputOptions {
|
|
5
4
|
name: string;
|
|
@@ -23,7 +22,7 @@ class OfflineCreatePackOptions {
|
|
|
23
22
|
|
|
24
23
|
this.name = options.name;
|
|
25
24
|
this.styleURL = options.styleURL;
|
|
26
|
-
this.bounds =
|
|
25
|
+
this.bounds = makeNativeBounds(...options.bounds);
|
|
27
26
|
this.minZoom = options.minZoom;
|
|
28
27
|
this.maxZoom = options.maxZoom;
|
|
29
28
|
this.metadata = this._makeMetadata(options.metadata);
|
|
@@ -45,12 +44,6 @@ class OfflineCreatePackOptions {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
_makeLatLngBounds(bounds: [GeoJSON.Position, GeoJSON.Position]): string {
|
|
49
|
-
const ne = bounds[0];
|
|
50
|
-
const sw = bounds[1];
|
|
51
|
-
return toJSONString(makeLatLngBounds(ne, sw));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
47
|
_makeMetadata(metadata?: Record<string, any>): string {
|
|
55
48
|
return JSON.stringify({
|
|
56
49
|
...metadata,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { featureCollection, point } from "@turf/helpers";
|
|
1
2
|
import { NativeModules } from "react-native";
|
|
2
3
|
|
|
3
4
|
import { toJSONString } from "../../utils";
|
|
4
|
-
import { makePoint, makeFeatureCollection } from "../../utils/geoUtils";
|
|
5
5
|
|
|
6
6
|
const MapLibreGL = NativeModules.MLNModule;
|
|
7
7
|
|
|
@@ -86,18 +86,17 @@ export class SnapshotOptions {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
_createCenterCoordPoint(centerCoordinate: GeoJSON.Position): string {
|
|
89
|
-
|
|
90
|
-
return toJSONString(point);
|
|
89
|
+
return toJSONString(point(centerCoordinate));
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
_createBoundsCollection(bounds: GeoJSON.Position[]): string {
|
|
94
93
|
const features = [];
|
|
95
94
|
|
|
96
95
|
for (const bound of bounds) {
|
|
97
|
-
features.push(
|
|
96
|
+
features.push(point(bound));
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
return toJSONString(
|
|
99
|
+
return toJSONString(featureCollection(features));
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
|
|
@@ -28,7 +28,9 @@ export function transformStyle(
|
|
|
28
28
|
if (styleType === "color" && typeof rawStyle === "string") {
|
|
29
29
|
const color = processColor(rawStyle);
|
|
30
30
|
if (color === null || color === undefined || typeof color === "symbol") {
|
|
31
|
-
console.error(
|
|
31
|
+
console.error(
|
|
32
|
+
`@maplibre/maplibre-react-native: Invalid color value ${rawStyle}, using #ff0000 (red) instead`,
|
|
33
|
+
);
|
|
32
34
|
rawStyle = "ff0000";
|
|
33
35
|
} else {
|
|
34
36
|
rawStyle = color;
|
package/jest-setup.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* eslint-disable no-undef, import/no-extraneous-dependencies */
|
|
2
|
+
import "@testing-library/react-native/extend-expect";
|
|
3
|
+
import { NativeModules } from "react-native";
|
|
4
|
+
|
|
5
|
+
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
|
|
6
|
+
jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
|
|
7
|
+
|
|
8
|
+
function keyMirror(keys: string[]) {
|
|
9
|
+
const obj: Record<string, string> = {};
|
|
10
|
+
keys.forEach((key) => (obj[key] = key));
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Mock of what the native code puts on the JS object
|
|
15
|
+
NativeModules.MLNModule = {
|
|
16
|
+
// constants
|
|
17
|
+
UserTrackingModes: keyMirror([
|
|
18
|
+
"None",
|
|
19
|
+
"Follow",
|
|
20
|
+
"FollowWithCourse",
|
|
21
|
+
"FollowWithHeading",
|
|
22
|
+
]),
|
|
23
|
+
StyleURL: keyMirror(["Default"]),
|
|
24
|
+
EventTypes: keyMirror([
|
|
25
|
+
"MapClick",
|
|
26
|
+
"MapLongClick",
|
|
27
|
+
"RegionWillChange",
|
|
28
|
+
"RegionIsChanging",
|
|
29
|
+
"RegionDidChange",
|
|
30
|
+
"WillStartLoadingMap",
|
|
31
|
+
"DidFinishLoadingMap",
|
|
32
|
+
"DidFailLoadingMap",
|
|
33
|
+
"WillStartRenderingFrame",
|
|
34
|
+
"DidFinishRenderingFrame",
|
|
35
|
+
"DidFinishRenderingFrameFully",
|
|
36
|
+
"DidFinishLoadingStyle",
|
|
37
|
+
"SetCameraComplete",
|
|
38
|
+
]),
|
|
39
|
+
CameraModes: keyMirror(["Flight", "Ease", "None"]),
|
|
40
|
+
StyleSource: keyMirror(["DefaultSourceID"]),
|
|
41
|
+
InterpolationMode: keyMirror([
|
|
42
|
+
"Exponential",
|
|
43
|
+
"Categorical",
|
|
44
|
+
"Interval",
|
|
45
|
+
"Identity",
|
|
46
|
+
]),
|
|
47
|
+
LineJoin: keyMirror(["Bevel", "Round", "Miter"]),
|
|
48
|
+
LineCap: keyMirror(["Butt", "Round", "Square"]),
|
|
49
|
+
LineTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
50
|
+
CirclePitchScale: keyMirror(["Map", "Viewport"]),
|
|
51
|
+
CircleTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
52
|
+
FillExtrusionTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
53
|
+
FillTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
54
|
+
IconRotationAlignment: keyMirror(["Auto", "Map", "Viewport"]),
|
|
55
|
+
IconTextFit: keyMirror(["None", "Width", "Height", "Both"]),
|
|
56
|
+
IconTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
57
|
+
SymbolPlacement: keyMirror(["Line", "Point"]),
|
|
58
|
+
TextAnchor: keyMirror([
|
|
59
|
+
"Center",
|
|
60
|
+
"Left",
|
|
61
|
+
"Right",
|
|
62
|
+
"Top",
|
|
63
|
+
"Bottom",
|
|
64
|
+
"TopLeft",
|
|
65
|
+
"TopRight",
|
|
66
|
+
"BottomLeft",
|
|
67
|
+
"BottomRight",
|
|
68
|
+
]),
|
|
69
|
+
TextJustify: keyMirror(["Center", "Left", "Right"]),
|
|
70
|
+
TextPitchAlignment: keyMirror(["Auto", "Map", "Viewport"]),
|
|
71
|
+
TextRotationAlignment: keyMirror(["Auto", "Map", "Viewport"]),
|
|
72
|
+
TextTransform: keyMirror(["None", "Lowercase", "Uppercase"]),
|
|
73
|
+
TextTranslateAnchor: keyMirror(["Map", "Viewport"]),
|
|
74
|
+
LightAnchor: keyMirror(["Map", "Viewport"]),
|
|
75
|
+
OfflinePackDownloadState: keyMirror(["Inactive", "Active", "Complete"]),
|
|
76
|
+
OfflineCallbackName: keyMirror(["Progress", "Error"]),
|
|
77
|
+
|
|
78
|
+
// methods
|
|
79
|
+
setAccessToken: jest.fn(),
|
|
80
|
+
getAccessToken: () => Promise.resolve("test-token"),
|
|
81
|
+
setConnected: jest.fn(),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
NativeModules.MLNOfflineModule = {
|
|
85
|
+
createPack: (packOptions: any) => {
|
|
86
|
+
return Promise.resolve({
|
|
87
|
+
bounds: packOptions.bounds,
|
|
88
|
+
metadata: JSON.stringify({ name: packOptions.name }),
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
getPacks: () => Promise.resolve([]),
|
|
92
|
+
deletePack: () => Promise.resolve(),
|
|
93
|
+
getPackStatus: () => Promise.resolve({}),
|
|
94
|
+
pausePackDownload: () => Promise.resolve(),
|
|
95
|
+
resumePackDownload: () => Promise.resolve(),
|
|
96
|
+
setPackObserver: () => Promise.resolve(),
|
|
97
|
+
setTileCountLimit: jest.fn(),
|
|
98
|
+
setProgressEventThrottle: jest.fn(),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
NativeModules.MLNSnapshotModule = {
|
|
102
|
+
takeSnap: () => {
|
|
103
|
+
return Promise.resolve("file://test.png");
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
NativeModules.MLNLocationModule = {
|
|
108
|
+
getLastKnownLocation: jest.fn(),
|
|
109
|
+
setMinDisplacement: jest.fn(),
|
|
110
|
+
start: jest.fn(),
|
|
111
|
+
stop: jest.fn(),
|
|
112
|
+
pause: jest.fn(),
|
|
113
|
+
};
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: "@testing-library/react-native",
|
|
3
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
|
|
4
|
+
setupFilesAfterEnv: ["./jest-setup.ts"],
|
|
5
|
+
setupFiles: ["./__tests__/__mocks__/react-native.mock.js"],
|
|
6
|
+
modulePathIgnorePatterns: ["__tests__/__mocks__", "fixtures"],
|
|
7
|
+
collectCoverageFrom: ["javascript/**/*.{ts,tsx,js,jsx}"],
|
|
8
|
+
};
|
|
@@ -61,14 +61,14 @@ def $RCTMLN.post_install(installer)
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
Pod::Spec.new do |s|
|
|
64
|
-
s.name
|
|
65
|
-
s.summary = "React Native
|
|
64
|
+
s.name = "maplibre-react-native"
|
|
65
|
+
s.summary = "React Native library for creating maps with MapLibre Native"
|
|
66
66
|
s.version = package['version']
|
|
67
|
-
s.authors
|
|
68
|
-
s.homepage
|
|
69
|
-
s.source
|
|
70
|
-
s.license
|
|
71
|
-
s.platform
|
|
67
|
+
s.authors = { "MapLibre" => "" }
|
|
68
|
+
s.homepage = "https://github.com/maplibre/maplibre-react-native"
|
|
69
|
+
s.source = { :git => "https://github.com/maplibre/maplibre-react-native.git" }
|
|
70
|
+
s.license = "MIT"
|
|
71
|
+
s.platform = :ios, "8.0"
|
|
72
72
|
|
|
73
73
|
s.dependency 'React-Core'
|
|
74
74
|
s.dependency 'React'
|