@maplibre/maplibre-react-native 10.0.0-alpha.7 → 10.0.0-alpha.9

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 (151) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/rctmln/build.gradle +5 -5
  5. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerView.java +2 -2
  6. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerViewManager.java +6 -6
  7. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/RCTMLNMarkerView.java +5 -5
  8. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/RCTMLNPointAnnotation.java +9 -8
  9. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraStop.java +14 -12
  10. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraUpdateItem.java +10 -10
  11. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraUpdateQueue.java +1 -1
  12. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/RCTMLNCamera.java +26 -26
  13. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/RCTMLNCameraManager.java +1 -1
  14. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/images/RCTMLNImages.java +12 -12
  15. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/LocationComponentManager.java +9 -9
  16. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/RCTMLNNativeUserLocation.java +7 -7
  17. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/RCTMLNNativeUserLocationManager.java +1 -1
  18. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/LayerSourceInfo.java +9 -9
  19. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNAndroidTextureMapView.java +2 -2
  20. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNAndroidTextureMapViewManager.java +2 -2
  21. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapView.java +43 -43
  22. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapViewManager.java +6 -6
  23. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyle.java +3 -3
  24. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleFactory.java +14 -14
  25. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleFunctionParser.java +2 -2
  26. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleValue.java +2 -2
  27. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTLayer.java +8 -8
  28. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNBackgroundLayer.java +1 -1
  29. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNCircleLayer.java +2 -2
  30. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNFillExtrusionLayer.java +2 -2
  31. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNFillLayer.java +2 -2
  32. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNHeatmapLayer.java +2 -2
  33. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNLineLayer.java +2 -2
  34. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNRasterLayer.java +1 -1
  35. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNSymbolLayer.java +2 -2
  36. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/light/RCTMLNLight.java +6 -6
  37. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNImageSource.java +3 -3
  38. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNImageSourceManager.java +1 -1
  39. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNRasterSource.java +3 -3
  40. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNShapeSource.java +9 -9
  41. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNShapeSourceManager.java +1 -1
  42. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNTileSource.java +2 -2
  43. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNVectorSource.java +4 -4
  44. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTSource.java +7 -7
  45. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/FeatureClickEvent.java +2 -2
  46. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/MapClickEvent.java +1 -1
  47. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/PointAnnotationClickEvent.java +2 -2
  48. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/PointAnnotationDragEvent.java +2 -2
  49. package/android/rctmln/src/main/java/com/maplibre/rctmln/location/LocationManager.java +6 -6
  50. package/android/rctmln/src/main/java/com/maplibre/rctmln/location/UserLocation.java +1 -1
  51. package/android/rctmln/src/main/java/com/maplibre/rctmln/location/UserTrackingMode.java +3 -3
  52. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLocationModule.java +2 -2
  53. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLogging.java +2 -2
  54. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNModule.java +8 -8
  55. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNOfflineModule.java +11 -11
  56. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNSnapshotModule.java +7 -7
  57. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/ClusterPropertyEntry.java +1 -1
  58. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/DownloadMapImageTask.java +5 -5
  59. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/ExpressionParser.java +2 -2
  60. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/GeoJSONUtils.java +13 -13
  61. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/GeoViewport.java +3 -3
  62. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/SimpleEventCallback.java +2 -2
  63. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/SphericalMercator.java +1 -1
  64. package/docs/Camera.md +1 -1
  65. package/docs/MapView.md +9 -9
  66. package/docs/MarkerView.md +1 -1
  67. package/docs/NativeUserLocation.md +1 -1
  68. package/docs/PointAnnotation.md +2 -2
  69. package/docs/UserLocation.md +2 -2
  70. package/docs/docs.json +12 -12
  71. package/javascript/@types/assets.d.ts +1 -1
  72. package/javascript/MLNModule.ts +2 -2
  73. package/javascript/Maplibre.ts +37 -42
  74. package/javascript/components/BackgroundLayer.tsx +9 -9
  75. package/javascript/components/Callout.tsx +19 -19
  76. package/javascript/components/Camera.tsx +29 -29
  77. package/javascript/components/CircleLayer.tsx +9 -9
  78. package/javascript/components/FillExtrusionLayer.tsx +9 -9
  79. package/javascript/components/FillLayer.tsx +9 -9
  80. package/javascript/components/HeadingIndicator.tsx +7 -8
  81. package/javascript/components/HeatmapLayer.tsx +10 -10
  82. package/javascript/components/ImageSource.tsx +8 -8
  83. package/javascript/components/Images.tsx +19 -20
  84. package/javascript/components/Light.tsx +15 -15
  85. package/javascript/components/LineLayer.tsx +9 -9
  86. package/javascript/components/MapView.tsx +74 -70
  87. package/javascript/components/MarkerView.tsx +9 -10
  88. package/javascript/components/NativeUserLocation.tsx +4 -4
  89. package/javascript/components/PointAnnotation.tsx +17 -17
  90. package/javascript/components/RasterLayer.tsx +9 -9
  91. package/javascript/components/RasterSource.tsx +10 -10
  92. package/javascript/components/ShapeSource.tsx +63 -61
  93. package/javascript/components/Style.tsx +69 -59
  94. package/javascript/components/SymbolLayer.tsx +10 -10
  95. package/javascript/components/UserLocation.tsx +23 -23
  96. package/javascript/components/VectorSource.tsx +19 -19
  97. package/javascript/components/annotations/Annotation.tsx +16 -15
  98. package/javascript/hooks/useAbstractLayer.ts +15 -12
  99. package/javascript/hooks/useAbstractSource.ts +2 -2
  100. package/javascript/hooks/useNativeBridge.ts +7 -7
  101. package/javascript/hooks/useNativeRef.ts +2 -2
  102. package/javascript/hooks/useOnce.ts +1 -1
  103. package/javascript/index.ts +2 -2
  104. package/javascript/modules/location/locationManager.ts +4 -4
  105. package/javascript/modules/offline/OfflineCreatePackOptions.ts +5 -5
  106. package/javascript/modules/offline/OfflinePack.ts +3 -3
  107. package/javascript/modules/offline/offlineManager.ts +11 -12
  108. package/javascript/modules/snapshot/SnapshotOptions.ts +4 -4
  109. package/javascript/modules/snapshot/snapshotManager.ts +2 -2
  110. package/javascript/requestAndroidLocationPermissions.ts +3 -3
  111. package/javascript/types/OnPressEvent.ts +1 -1
  112. package/javascript/types/index.ts +6 -2
  113. package/javascript/utils/BridgeValue.ts +20 -20
  114. package/javascript/utils/Logger.ts +14 -14
  115. package/javascript/utils/MaplibreStyles.d.ts +359 -359
  116. package/javascript/utils/StyleValue.ts +12 -12
  117. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +6 -6
  118. package/javascript/utils/animated/Animated.ts +38 -16
  119. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +7 -11
  120. package/javascript/utils/animated/AnimatedExtractCoordinateFromArray.ts +3 -3
  121. package/javascript/utils/animated/AnimatedPoint.ts +7 -7
  122. package/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts +16 -20
  123. package/javascript/utils/animated/AnimatedShape.ts +15 -15
  124. package/javascript/utils/deprecation.ts +6 -3
  125. package/javascript/utils/filterUtils.ts +1 -1
  126. package/javascript/utils/geoUtils.ts +8 -8
  127. package/javascript/utils/index.ts +14 -14
  128. package/javascript/utils/styleMap.ts +18 -18
  129. package/package.json +28 -15
  130. package/plugin/build/withMapLibre.d.ts +2 -2
  131. package/plugin/build/withMapLibre.js +24 -24
  132. package/scripts/autogenerate.js +1 -1
  133. package/scripts/templates/RCTMLNStyleFactory.java.ejs +14 -14
  134. package/.eslintignore +0 -3
  135. package/.eslintrc.js +0 -169
  136. package/.prettierrc.js +0 -7
  137. package/.yarn/sdks/eslint/bin/eslint.js +0 -27
  138. package/.yarn/sdks/eslint/lib/api.js +0 -27
  139. package/.yarn/sdks/eslint/lib/unsupported-api.js +0 -27
  140. package/.yarn/sdks/eslint/package.json +0 -14
  141. package/.yarn/sdks/integrations.yml +0 -5
  142. package/.yarn/sdks/prettier/bin/prettier.cjs +0 -27
  143. package/.yarn/sdks/prettier/index.cjs +0 -27
  144. package/.yarn/sdks/prettier/package.json +0 -7
  145. package/.yarn/sdks/typescript/bin/tsc +0 -27
  146. package/.yarn/sdks/typescript/bin/tsserver +0 -27
  147. package/.yarn/sdks/typescript/lib/tsc.js +0 -27
  148. package/.yarn/sdks/typescript/lib/tsserver.js +0 -239
  149. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -239
  150. package/.yarn/sdks/typescript/lib/typescript.js +0 -27
  151. package/.yarn/sdks/typescript/package.json +0 -10
@@ -1,30 +1,30 @@
1
- import {ExpressionField, FilterExpression} from '../utils/MaplibreStyles';
2
- import {BaseLayerProps} from '../hooks/useAbstractLayer';
3
-
4
- import CircleLayer from './CircleLayer';
5
- import RasterLayer from './RasterLayer';
6
- import SymbolLayer from './SymbolLayer';
7
- import LineLayer from './LineLayer';
8
- import FillLayer from './FillLayer';
9
- import FillExtrusionLayer from './FillExtrusionLayer';
10
- import BackgroundLayer from './BackgroundLayer';
11
- import HeatmapLayer from './HeatmapLayer';
12
- import VectorSource from './VectorSource';
13
- import RasterSource from './RasterSource';
14
- import ImageSource from './ImageSource';
15
- import ShapeSource from './ShapeSource';
16
-
17
1
  import React, {
18
2
  useMemo,
19
3
  useState,
20
4
  useEffect,
21
5
  ReactElement,
22
6
  ComponentType,
23
- } from 'react';
7
+ } from "react";
8
+
9
+ import BackgroundLayer, { BackgroundLayerProps } from "./BackgroundLayer";
10
+ import CircleLayer, { CircleLayerProps } from "./CircleLayer";
11
+ import FillExtrusionLayer, {
12
+ FillExtrusionLayerProps,
13
+ } from "./FillExtrusionLayer";
14
+ import FillLayer, { FillLayerProps } from "./FillLayer";
15
+ import HeatmapLayer, { HeatmapLayerProps } from "./HeatmapLayer";
16
+ import ImageSource from "./ImageSource";
17
+ import LineLayer, { LineLayerProps } from "./LineLayer";
18
+ import RasterLayer, { RasterLayerProps } from "./RasterLayer";
19
+ import RasterSource from "./RasterSource";
20
+ import ShapeSource from "./ShapeSource";
21
+ import SymbolLayer, { SymbolLayerProps } from "./SymbolLayer";
22
+ import VectorSource from "./VectorSource";
23
+ import { ExpressionField, FilterExpression } from "../utils/MaplibreStyles";
24
24
 
25
25
  function toCamelCase(s: string): string {
26
- return s.replace(/([-_][a-z])/gi, $1 => {
27
- return $1.toUpperCase().replace('-', '').replace('_', '');
26
+ return s.replace(/([-_][a-z])/gi, ($1) => {
27
+ return $1.toUpperCase().replace("-", "").replace("_", "");
28
28
  });
29
29
  }
30
30
 
@@ -37,9 +37,9 @@ function toCamelCaseKeys(
37
37
  return {};
38
38
  }
39
39
  const newObj: Record<string, unknown> = {};
40
- Object.keys(oldObj).forEach(key => {
40
+ Object.keys(oldObj).forEach((key) => {
41
41
  const value = oldObj[key];
42
- if (key.includes('-')) {
42
+ if (key.includes("-")) {
43
43
  newObj[toCamelCase(key)] = value;
44
44
  } else {
45
45
  newObj[key] = value;
@@ -48,27 +48,37 @@ function toCamelCaseKeys(
48
48
  return newObj;
49
49
  }
50
50
 
51
+ type LayerProps =
52
+ | CircleLayerProps
53
+ | SymbolLayerProps
54
+ | RasterLayerProps
55
+ | LineLayerProps
56
+ | FillLayerProps
57
+ | FillExtrusionLayerProps
58
+ | BackgroundLayerProps
59
+ | HeatmapLayerProps;
60
+
51
61
  function getLayerComponentType(
52
62
  layer: MaplibreJSONLayer,
53
- ): ComponentType<BaseLayerProps> | null {
54
- const {type} = layer;
63
+ ): ComponentType<LayerProps> | null {
64
+ const { type } = layer;
55
65
 
56
66
  switch (type) {
57
- case 'circle':
67
+ case "circle":
58
68
  return CircleLayer;
59
- case 'symbol':
69
+ case "symbol":
60
70
  return SymbolLayer;
61
- case 'raster':
71
+ case "raster":
62
72
  return RasterLayer;
63
- case 'line':
73
+ case "line":
64
74
  return LineLayer;
65
- case 'fill':
75
+ case "fill":
66
76
  return FillLayer;
67
- case 'fill-extrusion':
77
+ case "fill-extrusion":
68
78
  return FillExtrusionLayer;
69
- case 'background':
79
+ case "background":
70
80
  return BackgroundLayer;
71
- case 'heatmap':
81
+ case "heatmap":
72
82
  return HeatmapLayer;
73
83
  }
74
84
 
@@ -79,10 +89,10 @@ function getLayerComponentType(
79
89
 
80
90
  interface MaplibreJSONLayer {
81
91
  type: string;
82
- paint: {[k: string]: unknown};
83
- layout: {[k: string]: unknown};
92
+ paint: { [k: string]: unknown };
93
+ layout: { [k: string]: unknown };
84
94
  source?: string;
85
- 'source-layer'?: string;
95
+ "source-layer"?: string;
86
96
  minzoom?: number;
87
97
  maxzoom?: number;
88
98
  filter?: FilterExpression;
@@ -91,7 +101,7 @@ interface MaplibreJSONLayer {
91
101
 
92
102
  function asLayerComponent(
93
103
  layer: MaplibreJSONLayer,
94
- ): ReactElement<BaseLayerProps> | null {
104
+ ): ReactElement<LayerProps> | null {
95
105
  const LayerComponent = getLayerComponentType(layer);
96
106
 
97
107
  if (!LayerComponent) {
@@ -103,13 +113,13 @@ function asLayerComponent(
103
113
  ...toCamelCaseKeys(layer.layout),
104
114
  };
105
115
 
106
- const layerProps: Partial<BaseLayerProps> = {};
116
+ const layerProps: Partial<LayerProps> = {};
107
117
 
108
118
  if (layer.source) {
109
119
  layerProps.sourceID = layer.source;
110
120
  }
111
- if (layer['source-layer']) {
112
- layerProps.sourceLayerID = layer['source-layer'];
121
+ if (layer["source-layer"]) {
122
+ layerProps.sourceLayerID = layer["source-layer"];
113
123
  }
114
124
  if (layer.minzoom) {
115
125
  layerProps.minZoomLevel = layer.minzoom;
@@ -134,7 +144,7 @@ interface MaplibreJSONSource {
134
144
  minzoom?: number;
135
145
  maxzoom?: number;
136
146
  attribution?: string;
137
- scheme?: 'xyz' | 'tms';
147
+ scheme?: "xyz" | "tms";
138
148
  bounds?: number[];
139
149
  buffer?: number;
140
150
  tileSize?: number;
@@ -148,7 +158,7 @@ interface MaplibreJSONSource {
148
158
  clusterMaxZoom?: number;
149
159
  clusterMinPoints?: number;
150
160
  clusterRadius?: number;
151
- clusterProperties?: {[propertyName: string]: ExpressionField};
161
+ clusterProperties?: { [propertyName: string]: ExpressionField };
152
162
  data?: string | object;
153
163
  filter?: FilterExpression;
154
164
  generateId?: boolean;
@@ -182,19 +192,19 @@ function getTileSourceProps(source: MaplibreJSONSource): SourceProps {
182
192
  if (source.attribution) {
183
193
  sourceProps.attribution = source.attribution;
184
194
  }
185
- if (source.scheme && source.scheme === 'tms') {
195
+ if (source.scheme && source.scheme === "tms") {
186
196
  sourceProps.tms = true;
187
197
  }
188
198
  return sourceProps;
189
199
  }
190
200
 
191
201
  function getVectorSource(id: string, source: MaplibreJSONSource): ReactElement {
192
- const sourceProps = {...getTileSourceProps(source)};
202
+ const sourceProps = { ...getTileSourceProps(source) };
193
203
  return <VectorSource key={id} id={id} {...sourceProps} />;
194
204
  }
195
205
 
196
206
  function getRasterSource(id: string, source: MaplibreJSONSource): ReactElement {
197
- const sourceProps: SourceProps & {tileSize?: number} = {
207
+ const sourceProps: SourceProps & { tileSize?: number } = {
198
208
  ...getTileSourceProps(source),
199
209
  };
200
210
  if (source.tileSize) {
@@ -211,7 +221,7 @@ function getImageSource(id: string, source: MaplibreJSONSource): ReactElement {
211
221
  return <ImageSource key={id} id={id} {...sourceProps} />;
212
222
  }
213
223
 
214
- type ShapeSourceShape = (typeof ShapeSource.prototype.props)['shape'];
224
+ type ShapeSourceShape = (typeof ShapeSource.prototype.props)["shape"];
215
225
 
216
226
  function getShapeSource(id: string, source: MaplibreJSONSource): ReactElement {
217
227
  const sourceProps: SourceProps & {
@@ -219,14 +229,14 @@ function getShapeSource(id: string, source: MaplibreJSONSource): ReactElement {
219
229
  cluster?: boolean;
220
230
  clusterRadius?: number;
221
231
  clusterMaxZoomLevel?: number;
222
- clusterProperties?: {[propertyName: string]: ExpressionField};
232
+ clusterProperties?: { [propertyName: string]: ExpressionField };
223
233
  buffer?: number;
224
234
  tolerance?: number;
225
235
  lineMetrics?: boolean;
226
236
  } = {};
227
- if (source.data && typeof source.data === 'string') {
237
+ if (source.data && typeof source.data === "string") {
228
238
  sourceProps.url = source.data;
229
- } else if (source.data && typeof source.data === 'object') {
239
+ } else if (source.data && typeof source.data === "object") {
230
240
  sourceProps.shape = source.data as ShapeSourceShape;
231
241
  }
232
242
  if (source.cluster !== undefined) {
@@ -261,13 +271,13 @@ function asSourceComponent(
261
271
  source: MaplibreJSONSource,
262
272
  ): ReactElement | null {
263
273
  switch (source.type) {
264
- case 'vector':
274
+ case "vector":
265
275
  return getVectorSource(id, source);
266
- case 'raster':
276
+ case "raster":
267
277
  return getRasterSource(id, source);
268
- case 'image':
278
+ case "image":
269
279
  return getImageSource(id, source);
270
- case 'geojson':
280
+ case "geojson":
271
281
  return getShapeSource(id, source);
272
282
  }
273
283
 
@@ -278,7 +288,7 @@ function asSourceComponent(
278
288
 
279
289
  interface MaplibreJSON {
280
290
  layers?: MaplibreJSONLayer[];
281
- sources?: {[key: string]: MaplibreJSONSource};
291
+ sources?: { [key: string]: MaplibreJSONSource };
282
292
  }
283
293
 
284
294
  interface StyleProps {
@@ -298,7 +308,7 @@ interface StyleProps {
298
308
  const Style = (props: StyleProps): ReactElement => {
299
309
  const [fetchedJson, setFetchedJson] = useState({});
300
310
  const json: MaplibreJSON =
301
- typeof props.json === 'object' ? props.json : fetchedJson;
311
+ typeof props.json === "object" ? props.json : fetchedJson;
302
312
 
303
313
  // Fetch style when props.json is a URL
304
314
  useEffect(() => {
@@ -311,14 +321,14 @@ const Style = (props: StyleProps): ReactElement => {
311
321
  const responseJson = await response.json();
312
322
  setFetchedJson(responseJson);
313
323
  } catch (error: unknown) {
314
- const e = error as {name?: string};
315
- if (e.name === 'AbortError') {
324
+ const e = error as { name?: string };
325
+ if (e.name === "AbortError") {
316
326
  return;
317
327
  }
318
328
  throw e;
319
329
  }
320
330
  };
321
- if (typeof props.json === 'string') {
331
+ if (typeof props.json === "string") {
322
332
  fetchStyleJson(props.json);
323
333
  }
324
334
  return function cleanup(): void {
@@ -338,13 +348,13 @@ const Style = (props: StyleProps): ReactElement => {
338
348
 
339
349
  // Extract source components from json
340
350
  const sourceComponents = useMemo(() => {
341
- const {sources} = json;
351
+ const { sources } = json;
342
352
  if (!sources || !Object.keys(sources)) {
343
353
  return [];
344
354
  }
345
355
  return Object.keys(sources)
346
- .map(id => asSourceComponent(id, sources[id]))
347
- .filter(x => !!x);
356
+ .map((id) => asSourceComponent(id, sources[id]))
357
+ .filter((x) => !!x);
348
358
  }, [json]);
349
359
 
350
360
  return (
@@ -1,16 +1,16 @@
1
- import {type SymbolLayerStyleProps} from '../utils/MaplibreStyles';
2
- import BaseProps from '../types/BaseProps';
1
+ import React, { ReactElement } from "react";
2
+ import { View, NativeModules, requireNativeComponent } from "react-native";
3
+
3
4
  import useAbstractLayer, {
4
5
  BaseLayerProps,
5
6
  NativeBaseProps,
6
- } from '../hooks/useAbstractLayer';
7
-
8
- import React, {ReactElement} from 'react';
9
- import {View, NativeModules, requireNativeComponent} from 'react-native';
7
+ } from "../hooks/useAbstractLayer";
8
+ import BaseProps from "../types/BaseProps";
9
+ import { type SymbolLayerStyleProps } from "../utils/MaplibreStyles";
10
10
 
11
11
  const MapLibreGL = NativeModules.MLNModule;
12
12
 
13
- export const NATIVE_MODULE_NAME = 'RCTMLNSymbolLayer';
13
+ export const NATIVE_MODULE_NAME = "RCTMLNSymbolLayer";
14
14
 
15
15
  export interface SymbolLayerProps extends BaseProps, BaseLayerProps {
16
16
  /**
@@ -25,7 +25,7 @@ export interface SymbolLayerProps extends BaseProps, BaseLayerProps {
25
25
  children?: ReactElement | ReactElement[];
26
26
  }
27
27
 
28
- interface NativeProps extends Omit<SymbolLayerProps, 'style'>, NativeBaseProps {
28
+ interface NativeProps extends Omit<SymbolLayerProps, "style">, NativeBaseProps {
29
29
  snapshot: boolean;
30
30
  }
31
31
 
@@ -39,7 +39,7 @@ const SymbolLayer: React.FC<SymbolLayerProps> = ({
39
39
  sourceID = MapLibreGL.StyleSource.DefaultSourceID,
40
40
  ...props
41
41
  }: SymbolLayerProps) => {
42
- const {baseProps, setNativeLayer} = useAbstractLayer<
42
+ const { baseProps, setNativeLayer } = useAbstractLayer<
43
43
  SymbolLayerProps,
44
44
  NativeBaseProps
45
45
  >({
@@ -54,7 +54,7 @@ const SymbolLayer: React.FC<SymbolLayerProps> = ({
54
54
  return isSnapshot;
55
55
  }
56
56
 
57
- React.Children.forEach(props.children, child => {
57
+ React.Children.forEach(props.children, (child) => {
58
58
  if (child?.type === View) {
59
59
  isSnapshot = true;
60
60
  }
@@ -1,31 +1,30 @@
1
- import locationManager, {Location} from '../modules/location/locationManager';
2
- import {CircleLayerStyleProps} from '../utils/MaplibreStyles';
1
+ import React, { ReactElement, useEffect, useImperativeHandle } from "react";
3
2
 
4
- import Annotation from './annotations/Annotation';
5
- import CircleLayer from './CircleLayer';
6
- import HeadingIndicator from './HeadingIndicator';
7
- import NativeUserLocation from './NativeUserLocation';
3
+ import CircleLayer from "./CircleLayer";
4
+ import HeadingIndicator from "./HeadingIndicator";
5
+ import NativeUserLocation from "./NativeUserLocation";
6
+ import Annotation from "./annotations/Annotation";
7
+ import locationManager, { Location } from "../modules/location/locationManager";
8
+ import { CircleLayerStyleProps } from "../utils/MaplibreStyles";
8
9
 
9
- import React, {ReactElement, useEffect, useImperativeHandle} from 'react';
10
-
11
- const mapboxBlue = 'rgba(51, 181, 229, 100)';
10
+ const mapboxBlue = "rgba(51, 181, 229, 100)";
12
11
 
13
12
  const layerStyles: Record<string, CircleLayerStyleProps> = {
14
13
  pluse: {
15
14
  circleRadius: 15,
16
15
  circleColor: mapboxBlue,
17
16
  circleOpacity: 0.2,
18
- circlePitchAlignment: 'map',
17
+ circlePitchAlignment: "map",
19
18
  },
20
19
  background: {
21
20
  circleRadius: 9,
22
- circleColor: '#fff',
23
- circlePitchAlignment: 'map',
21
+ circleColor: "#fff",
22
+ circlePitchAlignment: "map",
24
23
  },
25
24
  foreground: {
26
25
  circleRadius: 6,
27
26
  circleColor: mapboxBlue,
28
- circlePitchAlignment: 'map',
27
+ circlePitchAlignment: "map",
29
28
  },
30
29
  };
31
30
 
@@ -50,7 +49,7 @@ export const normalIcon = (
50
49
  style={layerStyles.foreground}
51
50
  />,
52
51
  ...(showsUserHeadingIndicator && heading
53
- ? [HeadingIndicator({heading})]
52
+ ? [HeadingIndicator({ heading })]
54
53
  : []),
55
54
  ];
56
55
 
@@ -63,7 +62,7 @@ interface UserLocationProps {
63
62
  * Which render mode to use.
64
63
  * Can either be `normal` or `native`
65
64
  */
66
- renderMode?: 'normal' | 'native';
65
+ renderMode?: "normal" | "native";
67
66
  /**
68
67
  * native/android only render mode
69
68
  *
@@ -73,7 +72,7 @@ interface UserLocationProps {
73
72
  *
74
73
  * @platform android
75
74
  */
76
- androidRenderMode?: 'normal' | 'compass' | 'gps';
75
+ androidRenderMode?: "normal" | "compass" | "gps";
77
76
  /**
78
77
  * Whether location icon is visible
79
78
  */
@@ -109,12 +108,12 @@ interface UserLocationState {
109
108
  }
110
109
 
111
110
  export enum UserLocationRenderMode {
112
- Native = 'native',
113
- Normal = 'normal',
111
+ Native = "native",
112
+ Normal = "normal",
114
113
  }
115
114
 
116
115
  export interface UserLocationRef {
117
- setLocationManager: (props: {running: boolean}) => Promise<void>;
116
+ setLocationManager: (props: { running: boolean }) => Promise<void>;
118
117
  needsLocationManagerRunning: () => boolean;
119
118
  _onLocationUpdate: (location: Location | null) => void;
120
119
  }
@@ -127,7 +126,7 @@ const UserLocation = React.memo(
127
126
  visible = true,
128
127
  showsUserHeadingIndicator = false,
129
128
  minDisplacement = 0,
130
- renderMode = 'normal',
129
+ renderMode = "normal",
131
130
  androidRenderMode,
132
131
  children,
133
132
  onUpdate,
@@ -183,7 +182,7 @@ const UserLocation = React.memo(
183
182
 
184
183
  return (): void => {
185
184
  _isMounted.current = false;
186
- setLocationManager({running: false});
185
+ setLocationManager({ running: false });
187
186
  };
188
187
  // eslint-disable-next-line react-hooks/exhaustive-deps
189
188
  }, []);
@@ -236,7 +235,7 @@ const UserLocation = React.memo(
236
235
  let heading;
237
236
 
238
237
  if (location && location.coords) {
239
- const {longitude, latitude} = location.coords;
238
+ const { longitude, latitude } = location.coords;
240
239
  heading = location.coords.heading;
241
240
  coordinates = [longitude, latitude];
242
241
  }
@@ -277,7 +276,8 @@ const UserLocation = React.memo(
277
276
  coordinates={userLocationState.coordinates}
278
277
  style={{
279
278
  iconRotate: userLocationState.heading,
280
- }}>
279
+ }}
280
+ >
281
281
  {children ||
282
282
  normalIcon(showsUserHeadingIndicator, userLocationState.heading)}
283
283
  </Annotation>
@@ -1,23 +1,23 @@
1
- import {FilterExpression} from '../utils/MaplibreStyles';
2
- import {cloneReactChildrenWithProps, isFunction, isAndroid} from '../utils';
3
- import {getFilter} from '../utils/filterUtils';
4
- import {copyPropertiesAsDeprecated} from '../utils/deprecation';
5
- import BaseProps from '../types/BaseProps';
6
- import OnPressEvent from '../types/OnPressEvent';
7
- import useAbstractSource from '../hooks/useAbstractSource';
8
- import useNativeBridge from '../hooks/useNativeBridge';
9
-
10
- import React, {memo, useImperativeHandle} from 'react';
1
+ import { featureCollection } from "@turf/helpers";
2
+ import React, { memo, useImperativeHandle } from "react";
11
3
  import {
12
4
  NativeModules,
13
5
  NativeSyntheticEvent,
14
6
  requireNativeComponent,
15
- } from 'react-native';
16
- import {featureCollection} from '@turf/helpers';
7
+ } from "react-native";
8
+
9
+ import useAbstractSource from "../hooks/useAbstractSource";
10
+ import useNativeBridge from "../hooks/useNativeBridge";
11
+ import BaseProps from "../types/BaseProps";
12
+ import OnPressEvent from "../types/OnPressEvent";
13
+ import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils";
14
+ import { FilterExpression } from "../utils/MaplibreStyles";
15
+ import { copyPropertiesAsDeprecated } from "../utils/deprecation";
16
+ import { getFilter } from "../utils/filterUtils";
17
17
 
18
18
  const MapLibreGL = NativeModules.MLNModule;
19
19
 
20
- export const NATIVE_MODULE_NAME = 'RCTMLNVectorSource';
20
+ export const NATIVE_MODULE_NAME = "RCTMLNVectorSource";
21
21
 
22
22
  interface VectorSourceProps extends BaseProps {
23
23
  /**
@@ -122,7 +122,7 @@ const VectorSource = memo(
122
122
  // _runPendingNativeCommands,
123
123
  _onAndroidCallback,
124
124
  } = useNativeBridge(NATIVE_MODULE_NAME);
125
- const {setNativeRef, _nativeRef} = useAbstractSource<NativeProps>();
125
+ const { setNativeRef, _nativeRef } = useAbstractSource<NativeProps>();
126
126
 
127
127
  // const _setNativeRef = (
128
128
  // nativeRef: (Component<NativeProps> & Readonly<NativeMethods>) | null,
@@ -140,8 +140,8 @@ const VectorSource = memo(
140
140
  if (!_nativeRef) {
141
141
  return featureCollection([]);
142
142
  }
143
- const res: {data: string | GeoJSON.FeatureCollection} =
144
- await _runNativeCommand('features', _nativeRef, [
143
+ const res: { data: string | GeoJSON.FeatureCollection } =
144
+ await _runNativeCommand("features", _nativeRef, [
145
145
  [[layerIDs, getFilter(filter)]],
146
146
  ]);
147
147
 
@@ -153,16 +153,16 @@ const VectorSource = memo(
153
153
  };
154
154
 
155
155
  const onPress = (
156
- event: NativeSyntheticEvent<{payload: OnPressEvent}>,
156
+ event: NativeSyntheticEvent<{ payload: OnPressEvent }>,
157
157
  ): void => {
158
- const {onPress} = props;
158
+ const { onPress } = props;
159
159
 
160
160
  if (!onPress) {
161
161
  return;
162
162
  }
163
163
  const {
164
164
  nativeEvent: {
165
- payload: {features, coordinates, point},
165
+ payload: { features, coordinates, point },
166
166
  },
167
167
  } = event;
168
168
  let newEvent = {
@@ -1,16 +1,16 @@
1
- import SymbolLayer from '../SymbolLayer';
2
- import Animated from '../../utils/animated/Animated';
3
- import AnimatedMapPoint from '../../utils/animated/AnimatedPoint';
4
- import OnPressEvent from '../../types/OnPressEvent';
5
- import {SymbolLayerStyleProps} from '../../utils/MaplibreStyles';
6
-
7
1
  import React, {
8
2
  ReactElement,
9
3
  useCallback,
10
4
  useEffect,
11
5
  useImperativeHandle,
12
- } from 'react';
13
- import {Animated as RNAnimated, Easing} from 'react-native';
6
+ } from "react";
7
+ import { Animated as RNAnimated, Easing } from "react-native";
8
+
9
+ import OnPressEvent from "../../types/OnPressEvent";
10
+ import { SymbolLayerStyleProps } from "../../utils/MaplibreStyles";
11
+ import { AnimatedShapeSource } from "../../utils/animated/Animated";
12
+ import AnimatedMapPoint from "../../utils/animated/AnimatedPoint";
13
+ import SymbolLayer from "../SymbolLayer";
14
14
 
15
15
  interface AnnotationProps {
16
16
  id: string;
@@ -29,7 +29,7 @@ type Shape = AnimatedMapPoint | GeoJSON.Point;
29
29
  function getShapeFromProps(props: Partial<AnnotationProps> = {}): Shape {
30
30
  const lng = props.coordinates?.[0] || 0;
31
31
  const lat = props.coordinates?.[1] || 0;
32
- const point: GeoJSON.Point = {type: 'Point', coordinates: [lng, lat]};
32
+ const point: GeoJSON.Point = { type: "Point", coordinates: [lng, lat] };
33
33
 
34
34
  if (props.animated) {
35
35
  return new AnimatedMapPoint(point);
@@ -77,7 +77,7 @@ const Annotation = React.forwardRef<AnnotationRef, AnnotationProps>(
77
77
  );
78
78
 
79
79
  // this will run useEffect only when actual coordinates values change
80
- const coordinateDeps = props.coordinates?.join(',');
80
+ const coordinateDeps = props.coordinates?.join(",");
81
81
 
82
82
  useEffect(() => {
83
83
  if (!Array.isArray(props.coordinates)) {
@@ -127,7 +127,7 @@ const Annotation = React.forwardRef<AnnotationRef, AnnotationProps>(
127
127
 
128
128
  const children = [];
129
129
  const symbolStyle: SymbolLayerStyleProps | undefined = props.icon
130
- ? {...props.style, iconImage: props.icon}
130
+ ? { ...props.style, iconImage: props.icon }
131
131
  : undefined;
132
132
 
133
133
  if (symbolStyle) {
@@ -145,16 +145,17 @@ const Annotation = React.forwardRef<AnnotationRef, AnnotationProps>(
145
145
  }
146
146
 
147
147
  return (
148
- <Animated.ShapeSource
148
+ <AnimatedShapeSource
149
149
  id={props.id}
150
150
  onPress={_onPress}
151
- shape={shape as RNAnimated.WithAnimatedObject<GeoJSON.Point>}>
151
+ shape={shape as RNAnimated.WithAnimatedObject<GeoJSON.Point>}
152
+ >
152
153
  {children}
153
- </Animated.ShapeSource>
154
+ </AnimatedShapeSource>
154
155
  );
155
156
  },
156
157
  );
157
158
 
158
- Annotation.displayName = 'Annotation';
159
+ Annotation.displayName = "Annotation";
159
160
 
160
161
  export default Annotation;
@@ -1,15 +1,15 @@
1
- import {StyleValue, transformStyle} from '../utils/StyleValue';
2
- import {getFilter} from '../utils/filterUtils';
1
+ import React, { useMemo, useRef } from "react";
2
+ import { processColor, NativeMethods } from "react-native";
3
+
4
+ import BaseProps from "../types/BaseProps";
3
5
  import {
4
6
  AllLayerStyleProps,
5
7
  ExpressionField,
6
8
  ExpressionName,
7
9
  FilterExpression,
8
- } from '../utils/MaplibreStyles';
9
- import BaseProps from '../types/BaseProps';
10
-
11
- import React, {useMemo, useRef} from 'react';
12
- import {processColor, NativeMethods} from 'react-native';
10
+ } from "../utils/MaplibreStyles";
11
+ import { StyleValue, transformStyle } from "../utils/StyleValue";
12
+ import { getFilter } from "../utils/filterUtils";
13
13
 
14
14
  export interface BaseLayerProps {
15
15
  /**
@@ -57,7 +57,7 @@ export interface BaseLayerProps {
57
57
  }
58
58
 
59
59
  export interface NativeBaseProps {
60
- reactStyle?: {[key: string]: StyleValue};
60
+ reactStyle?: { [key: string]: StyleValue };
61
61
  }
62
62
 
63
63
  export default function useAbstractLayer<
@@ -71,7 +71,7 @@ export default function useAbstractLayer<
71
71
  instance: (React.Component<NativeProps> & Readonly<NativeMethods>) | null,
72
72
  ) => void;
73
73
  getStyleTypeFormatter: (styleType: string) => typeof processColor | undefined;
74
- setNativeProps: (nativeProps: {[key: string]: unknown}) => void;
74
+ setNativeProps: (nativeProps: { [key: string]: unknown }) => void;
75
75
  } {
76
76
  const nativeLayer = useRef<
77
77
  (React.Component<NativeProps> & Readonly<NativeMethods>) | null
@@ -102,14 +102,17 @@ export default function useAbstractLayer<
102
102
  const getStyleTypeFormatter = (
103
103
  styleType: string,
104
104
  ): typeof processColor | undefined => {
105
- return styleType === 'color' ? processColor : undefined;
105
+ return styleType === "color" ? processColor : undefined;
106
106
  };
107
107
 
108
- const setNativeProps = (nativeProps: {[key: string]: unknown}): void => {
108
+ const setNativeProps = (nativeProps: { [key: string]: unknown }): void => {
109
109
  if (nativeLayer.current) {
110
110
  let propsToPass = nativeProps;
111
111
  if (nativeProps.style) {
112
- propsToPass = {...nativeProps, reactStyle: transformStyle(props.style)};
112
+ propsToPass = {
113
+ ...nativeProps,
114
+ reactStyle: transformStyle(props.style),
115
+ };
113
116
  }
114
117
  nativeLayer.current.setNativeProps(propsToPass);
115
118
  }
@@ -1,5 +1,5 @@
1
- import React, {useRef} from 'react';
2
- import {NativeMethods} from 'react-native';
1
+ import React, { useRef } from "react";
2
+ import { NativeMethods } from "react-native";
3
3
 
4
4
  export default function useAbstractSource<NativePropsType extends object>(): {
5
5
  _nativeRef: