@maplibre/maplibre-react-native 10.0.0-beta.3 → 10.0.0-beta.7

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 (92) hide show
  1. package/android/build.gradle +98 -51
  2. package/android/gradle.properties +7 -0
  3. package/android/src/main/AndroidManifest.xml +4 -2
  4. package/android/src/main/AndroidManifestNew.xml +5 -0
  5. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java +0 -5
  6. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +0 -66
  7. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java +0 -28
  8. package/ios/MLRN/MLRNBackgroundLayer.h +0 -1
  9. package/ios/MLRN/MLRNFillExtrusionLayer.h +0 -1
  10. package/ios/MLRN/MLRNFillLayer.h +0 -1
  11. package/ios/MLRN/MLRNFillLayer.m +1 -0
  12. package/ios/MLRN/MLRNLineLayer.h +0 -1
  13. package/ios/MLRN/MLRNRasterLayer.h +0 -1
  14. package/ios/MLRN/MLRNShapeSource.h +0 -11
  15. package/ios/MLRN/MLRNShapeSource.m +0 -38
  16. package/ios/MLRN/MLRNShapeSourceManager.m +0 -68
  17. package/ios/MLRN/MLRNSymbolLayer.h +1 -7
  18. package/ios/MLRN/MLRNSymbolLayer.m +1 -89
  19. package/ios/MLRN/MLRNSymbolLayerManager.m +0 -1
  20. package/lib/commonjs/MapLibreRN.js +1 -13
  21. package/lib/commonjs/MapLibreRN.js.map +1 -1
  22. package/lib/commonjs/components/Images.js +1 -5
  23. package/lib/commonjs/components/Images.js.map +1 -1
  24. package/lib/commonjs/components/MapView.js +0 -7
  25. package/lib/commonjs/components/MapView.js.map +1 -1
  26. package/lib/commonjs/components/ShapeSource.js +6 -38
  27. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  28. package/lib/commonjs/components/SymbolLayer.js +2 -17
  29. package/lib/commonjs/components/SymbolLayer.js.map +1 -1
  30. package/lib/commonjs/components/VectorSource.js +1 -11
  31. package/lib/commonjs/components/VectorSource.js.map +1 -1
  32. package/lib/module/MapLibreRN.js +0 -4
  33. package/lib/module/MapLibreRN.js.map +1 -1
  34. package/lib/module/components/Images.js +1 -5
  35. package/lib/module/components/Images.js.map +1 -1
  36. package/lib/module/components/MapView.js +0 -7
  37. package/lib/module/components/MapView.js.map +1 -1
  38. package/lib/module/components/ShapeSource.js +5 -37
  39. package/lib/module/components/ShapeSource.js.map +1 -1
  40. package/lib/module/components/SymbolLayer.js +3 -18
  41. package/lib/module/components/SymbolLayer.js.map +1 -1
  42. package/lib/module/components/VectorSource.js +1 -11
  43. package/lib/module/components/VectorSource.js.map +1 -1
  44. package/lib/typescript/commonjs/src/MapLibreRN.d.ts +0 -4
  45. package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/components/Camera.d.ts +1 -1
  47. package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/components/MapView.d.ts +0 -1
  49. package/lib/typescript/commonjs/src/components/MapView.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +0 -1
  51. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts +0 -6
  53. package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/components/VectorSource.d.ts.map +1 -1
  55. package/lib/typescript/module/src/MapLibreRN.d.ts +0 -4
  56. package/lib/typescript/module/src/MapLibreRN.d.ts.map +1 -1
  57. package/lib/typescript/module/src/components/Camera.d.ts +1 -1
  58. package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
  59. package/lib/typescript/module/src/components/MapView.d.ts +0 -1
  60. package/lib/typescript/module/src/components/MapView.d.ts.map +1 -1
  61. package/lib/typescript/module/src/components/ShapeSource.d.ts +0 -1
  62. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  63. package/lib/typescript/module/src/components/SymbolLayer.d.ts +0 -6
  64. package/lib/typescript/module/src/components/SymbolLayer.d.ts.map +1 -1
  65. package/lib/typescript/module/src/components/VectorSource.d.ts.map +1 -1
  66. package/package.json +1 -1
  67. package/src/MapLibreRN.ts +0 -6
  68. package/src/components/Camera.tsx +1 -1
  69. package/src/components/Images.tsx +1 -10
  70. package/src/components/MapView.tsx +0 -11
  71. package/src/components/ShapeSource.tsx +5 -73
  72. package/src/components/SymbolLayer.tsx +5 -33
  73. package/src/components/VectorSource.tsx +4 -20
  74. package/android/src/main/res/values/strings.xml +0 -3
  75. package/lib/commonjs/components/Style.js +0 -266
  76. package/lib/commonjs/components/Style.js.map +0 -1
  77. package/lib/commonjs/utils/deprecation.js +0 -31
  78. package/lib/commonjs/utils/deprecation.js.map +0 -1
  79. package/lib/module/components/Style.js +0 -261
  80. package/lib/module/components/Style.js.map +0 -1
  81. package/lib/module/utils/deprecation.js +0 -27
  82. package/lib/module/utils/deprecation.js.map +0 -1
  83. package/lib/typescript/commonjs/src/components/Style.d.ts +0 -81
  84. package/lib/typescript/commonjs/src/components/Style.d.ts.map +0 -1
  85. package/lib/typescript/commonjs/src/utils/deprecation.d.ts +0 -6
  86. package/lib/typescript/commonjs/src/utils/deprecation.d.ts.map +0 -1
  87. package/lib/typescript/module/src/components/Style.d.ts +0 -81
  88. package/lib/typescript/module/src/components/Style.d.ts.map +0 -1
  89. package/lib/typescript/module/src/utils/deprecation.d.ts +0 -6
  90. package/lib/typescript/module/src/utils/deprecation.d.ts.map +0 -1
  91. package/src/components/Style.tsx +0 -371
  92. package/src/utils/deprecation.ts +0 -31
package/src/MapLibreRN.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { UserTrackingMode } from "./components/Camera";
2
-
3
1
  export * from "./MLRNModule";
4
2
  export {
5
3
  default as Camera,
@@ -40,7 +38,6 @@ export { default as SymbolLayer } from "./components/SymbolLayer";
40
38
  export { default as RasterLayer } from "./components/RasterLayer";
41
39
  export { default as BackgroundLayer } from "./components/BackgroundLayer";
42
40
  export { default as MarkerView } from "./components/MarkerView";
43
- export { default as Style } from "./components/Style";
44
41
 
45
42
  export {
46
43
  default as locationManager,
@@ -70,6 +67,3 @@ export type {
70
67
  BackgroundLayerStyleProps as BackgroundLayerStyle,
71
68
  LightLayerStyleProps as LightLayerStyle,
72
69
  } from "./utils/MapLibreRNStyles";
73
-
74
- /** @deprecated UserTrackingModes is deprecated use UserTrackingMode */
75
- export const UserTrackingModes = UserTrackingMode;
@@ -211,7 +211,7 @@ export interface CameraProps extends BaseProps, CameraStop {
211
211
  followUserLocation?: boolean;
212
212
 
213
213
  /**
214
- * 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)
214
+ * 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.UserTrackingMode` 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/SetUserTrackingMode.js)
215
215
  */
216
216
  followUserMode?: UserTrackingMode;
217
217
 
@@ -7,7 +7,6 @@ import {
7
7
  type ImageURISource,
8
8
  } from "react-native";
9
9
 
10
- import { SHAPE_SOURCE_NATIVE_ASSETS_KEY } from "./ShapeSource";
11
10
  import { type BaseProps } from "../types/BaseProps";
12
11
 
13
12
  export const NATIVE_MODULE_NAME = "MLRNImages";
@@ -84,15 +83,7 @@ const Images = ({
84
83
  const imageNames = Object.keys(images);
85
84
  for (const imageName of imageNames) {
86
85
  const value = images[imageName];
87
- if (
88
- imageName === SHAPE_SOURCE_NATIVE_ASSETS_KEY &&
89
- Array.isArray(value)
90
- ) {
91
- console.warn(
92
- `Use of ${SHAPE_SOURCE_NATIVE_ASSETS_KEY} in Images#images is deprecated please use Images#nativeAssetImages`,
93
- );
94
- nativeImages = value;
95
- } else if (value && _isUrlOrPath(value)) {
86
+ if (value && _isUrlOrPath(value)) {
96
87
  imagesResult[imageName] = value;
97
88
  } else if (value && _isImageSourcePropType(value)) {
98
89
  const res = Image.resolveAssetSource(value);
@@ -268,7 +268,6 @@ export interface MapViewRef {
268
268
  filter: FilterExpression | undefined,
269
269
  layerIDs: string[],
270
270
  ) => Promise<GeoJSON.FeatureCollection>;
271
- setCamera: () => void;
272
271
  takeSnap: (writeToDisk?: boolean) => Promise<string>;
273
272
  getZoom: () => Promise<number>;
274
273
  getCenter: () => Promise<GeoJSON.Position>;
@@ -359,10 +358,6 @@ const MapView = memo(
359
358
  * @return {GeoJSON.FeatureCollection}
360
359
  */
361
360
  queryRenderedFeaturesInRect,
362
- /**
363
- * Map camera will perform updates based on provided config. Deprecated use Camera#setCamera.
364
- */
365
- setCamera,
366
361
  /**
367
362
  * Takes snapshot of map with current tiles and returns a URI to the image
368
363
  * @param {Boolean} writeToDisk If true will create a temp file, otherwise it is in base64
@@ -571,12 +566,6 @@ const MapView = memo(
571
566
  return res.data as GeoJSON.FeatureCollection;
572
567
  };
573
568
 
574
- const setCamera = (): void => {
575
- console.warn(
576
- "MapView.setCamera is deprecated - please use Camera#setCamera",
577
- );
578
- };
579
-
580
569
  const takeSnap = async (writeToDisk = false): Promise<string> => {
581
570
  const res: { uri: string } = await _runNativeCommand(
582
571
  "takeSnap",
@@ -26,12 +26,10 @@ import {
26
26
  type ExpressionField,
27
27
  type FilterExpression,
28
28
  } from "../utils/MapLibreRNStyles";
29
- import { copyPropertiesAsDeprecated } from "../utils/deprecation";
30
29
  import { getFilter } from "../utils/filterUtils";
31
30
 
32
31
  const MapLibreRN = NativeModules.MLRNModule;
33
32
  export const NATIVE_MODULE_NAME = "MLRNShapeSource";
34
- export const SHAPE_SOURCE_NATIVE_ASSETS_KEY = "assets";
35
33
 
36
34
  interface NativeProps {
37
35
  shape?: string;
@@ -252,18 +250,6 @@ const ShapeSource = memo(
252
250
  async function getClusterExpansionZoom(
253
251
  feature: GeoJSON.Feature,
254
252
  ): Promise<number> {
255
- if (typeof feature === "number") {
256
- console.warn(
257
- "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
258
- );
259
- const res: { data: number } = await _runNativeCommand(
260
- "getClusterExpansionZoomById",
261
- _nativeRef.current,
262
- [feature],
263
- );
264
- return res.data;
265
- }
266
-
267
253
  const res: { data: number } = await _runNativeCommand(
268
254
  "getClusterExpansionZoom",
269
255
  _nativeRef.current,
@@ -277,24 +263,6 @@ const ShapeSource = memo(
277
263
  limit: number,
278
264
  offset: number,
279
265
  ): Promise<GeoJSON.FeatureCollection> {
280
- if (typeof feature === "number") {
281
- console.warn(
282
- "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
283
- );
284
- const res: { data: string | GeoJSON.FeatureCollection } =
285
- await _runNativeCommand(
286
- "getClusterLeavesById",
287
- _nativeRef.current,
288
- [feature, limit, offset],
289
- );
290
-
291
- if (isAndroid()) {
292
- return JSON.parse(res.data as string);
293
- }
294
-
295
- return res.data as GeoJSON.FeatureCollection;
296
- }
297
-
298
266
  const res: { data: string | GeoJSON.FeatureCollection } =
299
267
  await _runNativeCommand("getClusterLeaves", _nativeRef.current, [
300
268
  JSON.stringify(feature),
@@ -312,24 +280,6 @@ const ShapeSource = memo(
312
280
  async function getClusterChildren(
313
281
  feature: GeoJSON.Feature,
314
282
  ): Promise<GeoJSON.FeatureCollection> {
315
- if (typeof feature === "number") {
316
- console.warn(
317
- "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
318
- );
319
- const res: { data: string | GeoJSON.FeatureCollection } =
320
- await _runNativeCommand(
321
- "getClusterChildrenById",
322
- _nativeRef.current,
323
- [feature],
324
- );
325
-
326
- if (isAndroid()) {
327
- return JSON.parse(res.data as string);
328
- }
329
-
330
- return res.data as GeoJSON.FeatureCollection;
331
- }
332
-
333
283
  const res: { data: string | GeoJSON.FeatureCollection } =
334
284
  await _runNativeCommand("getClusterChildren", _nativeRef.current, [
335
285
  JSON.stringify(feature),
@@ -372,31 +322,13 @@ const ShapeSource = memo(
372
322
  payload: { features, coordinates, point },
373
323
  },
374
324
  } = event;
375
- let newEvent = {
376
- features,
377
- coordinates,
378
- point,
379
- };
380
- newEvent = copyPropertiesAsDeprecated(
381
- event,
382
- newEvent,
383
- (key: string): void => {
384
- console.warn(
385
- `event.${key} is deprecated on ShapeSource#onPress, please use event.features`,
386
- );
387
- },
388
- {
389
- nativeEvent: (
390
- origNativeEvent: NativeSyntheticEvent<{ payload: OnPressEvent }>,
391
- ) => ({
392
- ...origNativeEvent,
393
- payload: features[0],
394
- }),
395
- },
396
- );
397
325
 
398
326
  if (props.onPress) {
399
- props.onPress(newEvent);
327
+ props.onPress({
328
+ features,
329
+ coordinates,
330
+ point,
331
+ });
400
332
  }
401
333
  }
402
334
 
@@ -1,5 +1,4 @@
1
- import { Children, type ReactElement } from "react";
2
- import { View, NativeModules, requireNativeComponent } from "react-native";
1
+ import { NativeModules, requireNativeComponent } from "react-native";
3
2
 
4
3
  import useAbstractLayer, {
5
4
  type BaseLayerProps,
@@ -17,17 +16,11 @@ export interface SymbolLayerProps extends BaseProps, BaseLayerProps {
17
16
  * Customizable style attributes
18
17
  */
19
18
  style?: SymbolLayerStyleProps;
20
-
21
- /**
22
- * @deprecated passed children used to create an image with id of symbol in style and also set the iconImageName property accordingly.
23
- * This is now deprecated, use Image component instead.
24
- */
25
- children?: ReactElement | ReactElement[];
26
19
  }
27
20
 
28
- interface NativeProps extends Omit<SymbolLayerProps, "style">, NativeBaseProps {
29
- snapshot: boolean;
30
- }
21
+ interface NativeProps
22
+ extends Omit<SymbolLayerProps, "style">,
23
+ NativeBaseProps {}
31
24
 
32
25
  const MLRNSymbolLayer = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
33
26
 
@@ -46,32 +39,11 @@ const SymbolLayer: React.FC<SymbolLayerProps> = ({
46
39
  sourceID,
47
40
  });
48
41
 
49
- const _shouldSnapshot = (): boolean => {
50
- let isSnapshot = false;
51
-
52
- if (Children.count(props.children) <= 0) {
53
- return isSnapshot;
54
- }
55
-
56
- Children.forEach(props.children, (child) => {
57
- if (child?.type === View) {
58
- isSnapshot = true;
59
- }
60
- });
61
-
62
- return isSnapshot;
63
- };
64
-
65
42
  const updatedProps = {
66
43
  ...baseProps,
67
- snapshot: _shouldSnapshot(),
68
44
  };
69
45
 
70
- return (
71
- <MLRNSymbolLayer ref={setNativeLayer} {...updatedProps}>
72
- {props.children}
73
- </MLRNSymbolLayer>
74
- );
46
+ return <MLRNSymbolLayer ref={setNativeLayer} {...updatedProps} />;
75
47
  };
76
48
 
77
49
  export default SymbolLayer;
@@ -12,7 +12,6 @@ import { type BaseProps } from "../types/BaseProps";
12
12
  import { type OnPressEvent } from "../types/OnPressEvent";
13
13
  import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils";
14
14
  import { type FilterExpression } from "../utils/MapLibreRNStyles";
15
- import { copyPropertiesAsDeprecated } from "../utils/deprecation";
16
15
  import { getFilter } from "../utils/filterUtils";
17
16
 
18
17
  const MapLibreRN = NativeModules.MLRNModule;
@@ -160,33 +159,18 @@ const VectorSource = memo(
160
159
  if (!onPress) {
161
160
  return;
162
161
  }
162
+
163
163
  const {
164
164
  nativeEvent: {
165
165
  payload: { features, coordinates, point },
166
166
  },
167
167
  } = event;
168
- let newEvent = {
168
+
169
+ onPress({
169
170
  features,
170
171
  coordinates,
171
172
  point,
172
- };
173
- newEvent = copyPropertiesAsDeprecated(
174
- event,
175
- newEvent,
176
- (key: string) => {
177
- console.warn(
178
- `event.${key} is deprecated on VectorSource#onPress, please use event.features`,
179
- );
180
- },
181
- {
182
- nativeEvent: (origNativeEvent: OnPressEvent) => ({
183
- ...origNativeEvent,
184
- payload: features[0],
185
- }),
186
- },
187
- );
188
-
189
- onPress(newEvent);
173
+ });
190
174
  };
191
175
 
192
176
  const allProps = {
@@ -1,3 +0,0 @@
1
- <resources>
2
- <string name="app_name">MLRN</string>
3
- </resources>
@@ -1,266 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _BackgroundLayer = _interopRequireDefault(require("./BackgroundLayer.js"));
9
- var _CircleLayer = _interopRequireDefault(require("./CircleLayer.js"));
10
- var _FillExtrusionLayer = _interopRequireDefault(require("./FillExtrusionLayer.js"));
11
- var _FillLayer = _interopRequireDefault(require("./FillLayer.js"));
12
- var _HeatmapLayer = _interopRequireDefault(require("./HeatmapLayer.js"));
13
- var _ImageSource = _interopRequireDefault(require("./ImageSource.js"));
14
- var _LineLayer = _interopRequireDefault(require("./LineLayer.js"));
15
- var _RasterLayer = _interopRequireDefault(require("./RasterLayer.js"));
16
- var _RasterSource = _interopRequireDefault(require("./RasterSource.js"));
17
- var _ShapeSource = _interopRequireDefault(require("./ShapeSource.js"));
18
- var _SymbolLayer = _interopRequireDefault(require("./SymbolLayer.js"));
19
- var _VectorSource = _interopRequireDefault(require("./VectorSource.js"));
20
- var _jsxRuntime = require("react/jsx-runtime");
21
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- function toCamelCase(s) {
23
- return s.replace(/([-_][a-z])/gi, $1 => {
24
- return $1.toUpperCase().replace("-", "").replace("_", "");
25
- });
26
- }
27
-
28
- // Patches the Mapbox Style Specification keys into the style props attributes:
29
- // icon-allow-overlap -> iconAllowOverlap
30
- function toCamelCaseKeys(oldObj) {
31
- if (!oldObj) {
32
- return {};
33
- }
34
- const newObj = {};
35
- Object.keys(oldObj).forEach(key => {
36
- const value = oldObj[key];
37
- if (key.includes("-")) {
38
- newObj[toCamelCase(key)] = value;
39
- } else {
40
- newObj[key] = value;
41
- }
42
- });
43
- return newObj;
44
- }
45
- function getLayerComponentType(layer) {
46
- const {
47
- type
48
- } = layer;
49
- switch (type) {
50
- case "circle":
51
- return _CircleLayer.default;
52
- case "symbol":
53
- return _SymbolLayer.default;
54
- case "raster":
55
- return _RasterLayer.default;
56
- case "line":
57
- return _LineLayer.default;
58
- case "fill":
59
- return _FillLayer.default;
60
- case "fill-extrusion":
61
- return _FillExtrusionLayer.default;
62
- case "background":
63
- return _BackgroundLayer.default;
64
- case "heatmap":
65
- return _HeatmapLayer.default;
66
- }
67
- console.warn(`Mapbox layer type '${type}' is not supported/`);
68
- return null;
69
- }
70
- function asLayerComponent(layer) {
71
- const LayerComponent = getLayerComponentType(layer);
72
- if (!LayerComponent) {
73
- return null;
74
- }
75
- const style = {
76
- ...toCamelCaseKeys(layer.paint),
77
- ...toCamelCaseKeys(layer.layout)
78
- };
79
- const layerProps = {};
80
- if (layer.source) {
81
- layerProps.sourceID = layer.source;
82
- }
83
- if (layer["source-layer"]) {
84
- layerProps.sourceLayerID = layer["source-layer"];
85
- }
86
- if (layer.minzoom) {
87
- layerProps.minZoomLevel = layer.minzoom;
88
- }
89
- if (layer.maxzoom) {
90
- layerProps.maxZoomLevel = layer.maxzoom;
91
- }
92
- if (layer.filter) {
93
- layerProps.filter = layer.filter;
94
- }
95
- if (Object.keys(style).length) {
96
- layerProps.style = style;
97
- }
98
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(LayerComponent, {
99
- id: layer.id,
100
- ...layerProps
101
- }, layer.id);
102
- }
103
- function getTileSourceProps(source) {
104
- const sourceProps = {};
105
- if (source.url) {
106
- sourceProps.url = source.url;
107
- }
108
- if (source.tiles) {
109
- sourceProps.tileUrlTemplates = source.tiles;
110
- }
111
- if (source.minzoom !== undefined) {
112
- sourceProps.minZoomLevel = source.minzoom;
113
- }
114
- if (source.maxzoom !== undefined) {
115
- sourceProps.maxZoomLevel = source.maxzoom;
116
- }
117
- if (source.attribution) {
118
- sourceProps.attribution = source.attribution;
119
- }
120
- if (source.scheme && source.scheme === "tms") {
121
- sourceProps.tms = true;
122
- }
123
- return sourceProps;
124
- }
125
- function getVectorSource(id, source) {
126
- const sourceProps = {
127
- ...getTileSourceProps(source)
128
- };
129
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_VectorSource.default, {
130
- id: id,
131
- ...sourceProps
132
- }, id);
133
- }
134
- function getRasterSource(id, source) {
135
- const sourceProps = {
136
- ...getTileSourceProps(source)
137
- };
138
- if (source.tileSize) {
139
- sourceProps.tileSize = source.tileSize;
140
- }
141
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RasterSource.default, {
142
- id: id,
143
- ...sourceProps
144
- }, id);
145
- }
146
- function getImageSource(id, source) {
147
- const sourceProps = {
148
- url: source.url,
149
- coordinates: source.coordinates
150
- };
151
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageSource.default, {
152
- id: id,
153
- ...sourceProps
154
- }, id);
155
- }
156
- function getShapeSource(id, source) {
157
- const sourceProps = {};
158
- if (source.data && typeof source.data === "string") {
159
- sourceProps.url = source.data;
160
- } else if (source.data && typeof source.data === "object") {
161
- sourceProps.shape = source.data;
162
- }
163
- if (source.cluster !== undefined) {
164
- sourceProps.cluster = source.cluster;
165
- }
166
- if (source.clusterRadius !== undefined) {
167
- sourceProps.clusterRadius = source.clusterRadius;
168
- }
169
- if (source.maxzoom !== undefined) {
170
- sourceProps.maxZoomLevel = source.maxzoom;
171
- }
172
- if (source.clusterMaxZoom !== undefined) {
173
- sourceProps.clusterMaxZoomLevel = source.clusterMaxZoom;
174
- }
175
- if (source.clusterProperties !== undefined) {
176
- sourceProps.clusterProperties = source.clusterProperties;
177
- }
178
- if (source.buffer !== undefined) {
179
- sourceProps.buffer = source.buffer;
180
- }
181
- if (source.tolerance !== undefined) {
182
- sourceProps.tolerance = source.tolerance;
183
- }
184
- if (source.lineMetrics !== undefined) {
185
- sourceProps.lineMetrics = source.lineMetrics;
186
- }
187
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ShapeSource.default, {
188
- id: id,
189
- ...sourceProps
190
- }, id);
191
- }
192
- function asSourceComponent(id, source) {
193
- switch (source.type) {
194
- case "vector":
195
- return getVectorSource(id, source);
196
- case "raster":
197
- return getRasterSource(id, source);
198
- case "image":
199
- return getImageSource(id, source);
200
- case "geojson":
201
- return getShapeSource(id, source);
202
- }
203
- console.warn(`MapLibre source type '${source.type}' is not supported`);
204
- return null;
205
- }
206
- /**
207
- * Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
208
- * Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
209
- * Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
210
- *
211
- * TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
212
- */
213
- const Style = props => {
214
- const [fetchedJson, setFetchedJson] = (0, _react.useState)({});
215
- const json = typeof props.json === "object" ? props.json : fetchedJson;
216
-
217
- // Fetch style when props.json is a URL
218
- (0, _react.useEffect)(() => {
219
- const abortController = new AbortController();
220
- const fetchStyleJson = async url => {
221
- try {
222
- const response = await fetch(url, {
223
- signal: abortController.signal
224
- });
225
- const responseJson = await response.json();
226
- setFetchedJson(responseJson);
227
- } catch (error) {
228
- const e = error;
229
- if (e.name === "AbortError") {
230
- return;
231
- }
232
- throw e;
233
- }
234
- };
235
- if (typeof props.json === "string") {
236
- fetchStyleJson(props.json);
237
- }
238
- return function cleanup() {
239
- abortController.abort();
240
- };
241
- }, [props.json]);
242
-
243
- // Extract layer components from json
244
- const layerComponents = (0, _react.useMemo)(() => {
245
- if (!json.layers) {
246
- return [];
247
- }
248
- return json.layers.map(asLayerComponent).filter(x => !!x);
249
- }, [json.layers]);
250
-
251
- // Extract source components from json
252
- const sourceComponents = (0, _react.useMemo)(() => {
253
- const {
254
- sources
255
- } = json;
256
- if (!sources || !Object.keys(sources)) {
257
- return [];
258
- }
259
- return Object.entries(sources).map(([id, source]) => asSourceComponent(id, source)).filter(x => !!x);
260
- }, [json]);
261
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
262
- children: [sourceComponents, layerComponents]
263
- });
264
- };
265
- var _default = exports.default = Style;
266
- //# sourceMappingURL=Style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_BackgroundLayer","_interopRequireDefault","_CircleLayer","_FillExtrusionLayer","_FillLayer","_HeatmapLayer","_ImageSource","_LineLayer","_RasterLayer","_RasterSource","_ShapeSource","_SymbolLayer","_VectorSource","_jsxRuntime","e","__esModule","default","toCamelCase","s","replace","$1","toUpperCase","toCamelCaseKeys","oldObj","newObj","Object","keys","forEach","key","value","includes","getLayerComponentType","layer","type","CircleLayer","SymbolLayer","RasterLayer","LineLayer","FillLayer","FillExtrusionLayer","BackgroundLayer","HeatmapLayer","console","warn","asLayerComponent","LayerComponent","style","paint","layout","layerProps","source","sourceID","sourceLayerID","minzoom","minZoomLevel","maxzoom","maxZoomLevel","filter","length","jsx","id","getTileSourceProps","sourceProps","url","tiles","tileUrlTemplates","undefined","attribution","scheme","tms","getVectorSource","getRasterSource","tileSize","getImageSource","coordinates","getShapeSource","data","shape","cluster","clusterRadius","clusterMaxZoom","clusterMaxZoomLevel","clusterProperties","buffer","tolerance","lineMetrics","asSourceComponent","Style","props","fetchedJson","setFetchedJson","useState","json","useEffect","abortController","AbortController","fetchStyleJson","response","fetch","signal","responseJson","error","name","cleanup","abort","layerComponents","useMemo","layers","map","x","sourceComponents","sources","entries","jsxs","Fragment","children","_default","exports"],"sourceRoot":"../../../src","sources":["components/Style.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAA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exports, "__esModule", {
4
- value: true
5
- });
6
- exports.copyPropertiesAsDeprecated = copyPropertiesAsDeprecated;
7
- /**
8
- * Copy properties from origObject to newObject, which not exists in newObject,
9
- * calls onDeprecatedCalled callback in case a copied property is invoked.
10
- */
11
-
12
- function copyPropertiesAsDeprecated(origObject, newObject, onDeprecatedCalled, accessors = {}) {
13
- const result = {
14
- ...newObject
15
- };
16
- for (const [key, value] of Object.entries(origObject)) {
17
- if (!(key in newObject)) {
18
- Object.defineProperty(result, key, {
19
- get() {
20
- onDeprecatedCalled(key);
21
- return accessors[key] ? accessors[key](value) : value;
22
- },
23
- enumerable: true,
24
- // Ensure the property is enumerable
25
- configurable: true // Ensure the property can be reconfigured
26
- });
27
- }
28
- }
29
- return result;
30
- }
31
- //# sourceMappingURL=deprecation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["copyPropertiesAsDeprecated","origObject","newObject","onDeprecatedCalled","accessors","result","key","value","Object","entries","defineProperty","get","enumerable","configurable"],"sourceRoot":"../../../src","sources":["utils/deprecation.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEO,SAASA,0BAA0BA,CAIxCC,UAA0B,EAC1BC,SAA6B,EAC7BC,kBAAyC,EACzCC,SAAkD,GAAG,CAAC,CAAC,EACnC;EACpB,MAAMC,MAAM,GAAG;IAAE,GAAGH;EAAU,CAAC;EAE/B,KAAK,MAAM,CAACI,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,UAAU,CAAC,EAAE;IACrD,IAAI,EAAEK,GAAG,IAAIJ,SAAS,CAAC,EAAE;MACvBM,MAAM,CAACE,cAAc,CAACL,MAAM,EAAEC,GAAG,EAAE;QACjCK,GAAGA,CAAA,EAAG;UACJR,kBAAkB,CAACG,GAAG,CAAC;UACvB,OAAOF,SAAS,CAACE,GAAG,CAAC,GAAGF,SAAS,CAACE,GAAG,CAAC,CAACC,KAAK,CAAC,GAAGA,KAAK;QACvD,CAAC;QACDK,UAAU,EAAE,IAAI;QAAE;QAClBC,YAAY,EAAE,IAAI,CAAE;MACtB,CAAC,CAAC;IACJ;EACF;EAEA,OAAOR,MAAM;AACf","ignoreList":[]}