@maplibre/maplibre-react-native 10.0.0-alpha.6 → 10.0.0-alpha.8

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 (113) hide show
  1. package/.eslintrc.js +3 -1
  2. package/.yarn/sdks/eslint/bin/eslint.js +8 -1
  3. package/.yarn/sdks/eslint/lib/api.js +8 -1
  4. package/.yarn/sdks/eslint/lib/unsupported-api.js +8 -1
  5. package/.yarn/sdks/prettier/bin/prettier.cjs +8 -1
  6. package/.yarn/sdks/prettier/index.cjs +8 -1
  7. package/.yarn/sdks/typescript/bin/tsc +8 -1
  8. package/.yarn/sdks/typescript/bin/tsserver +8 -1
  9. package/.yarn/sdks/typescript/lib/tsc.js +8 -1
  10. package/.yarn/sdks/typescript/lib/tsserver.js +20 -6
  11. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +20 -6
  12. package/.yarn/sdks/typescript/lib/typescript.js +8 -1
  13. package/CHANGELOG.md +7 -0
  14. package/CONTRIBUTING.md +10 -9
  15. package/android/build.gradle +1 -1
  16. package/android/rctmln/build.gradle +5 -5
  17. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerView.java +2 -2
  18. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerViewManager.java +6 -6
  19. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/RCTMLNMarkerView.java +5 -5
  20. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/RCTMLNPointAnnotation.java +9 -8
  21. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraStop.java +14 -12
  22. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraUpdateItem.java +10 -10
  23. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraUpdateQueue.java +1 -1
  24. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/RCTMLNCamera.java +26 -26
  25. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/RCTMLNCameraManager.java +1 -1
  26. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/images/RCTMLNImages.java +12 -12
  27. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/LocationComponentManager.java +9 -9
  28. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/RCTMLNNativeUserLocation.java +7 -7
  29. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/RCTMLNNativeUserLocationManager.java +1 -1
  30. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/LayerSourceInfo.java +9 -9
  31. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNAndroidTextureMapView.java +2 -2
  32. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNAndroidTextureMapViewManager.java +2 -2
  33. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapView.java +43 -43
  34. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapViewManager.java +6 -6
  35. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyle.java +3 -3
  36. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleFactory.java +14 -14
  37. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleFunctionParser.java +2 -2
  38. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleValue.java +2 -2
  39. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTLayer.java +8 -8
  40. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNBackgroundLayer.java +1 -1
  41. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNCircleLayer.java +2 -2
  42. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNFillExtrusionLayer.java +2 -2
  43. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNFillLayer.java +2 -2
  44. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNHeatmapLayer.java +2 -2
  45. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNLineLayer.java +2 -2
  46. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNRasterLayer.java +1 -1
  47. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNSymbolLayer.java +2 -2
  48. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/light/RCTMLNLight.java +6 -6
  49. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNImageSource.java +3 -3
  50. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNImageSourceManager.java +1 -1
  51. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNRasterSource.java +3 -3
  52. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNShapeSource.java +9 -9
  53. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNShapeSourceManager.java +1 -1
  54. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNTileSource.java +2 -2
  55. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNVectorSource.java +4 -4
  56. package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTSource.java +7 -7
  57. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/FeatureClickEvent.java +2 -2
  58. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/MapClickEvent.java +1 -1
  59. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/PointAnnotationClickEvent.java +2 -2
  60. package/android/rctmln/src/main/java/com/maplibre/rctmln/events/PointAnnotationDragEvent.java +2 -2
  61. package/android/rctmln/src/main/java/com/maplibre/rctmln/location/LocationManager.java +6 -6
  62. package/android/rctmln/src/main/java/com/maplibre/rctmln/location/UserLocation.java +1 -1
  63. package/android/rctmln/src/main/java/com/maplibre/rctmln/location/UserTrackingMode.java +3 -3
  64. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLocationModule.java +2 -2
  65. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLogging.java +2 -2
  66. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNModule.java +8 -8
  67. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNOfflineModule.java +11 -11
  68. package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNSnapshotModule.java +7 -7
  69. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/ClusterPropertyEntry.java +1 -1
  70. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/DownloadMapImageTask.java +5 -5
  71. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/ExpressionParser.java +2 -2
  72. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/GeoJSONUtils.java +13 -13
  73. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/GeoViewport.java +3 -3
  74. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/SimpleEventCallback.java +2 -2
  75. package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/SphericalMercator.java +1 -1
  76. package/docs/Camera.md +3 -3
  77. package/docs/MapView.md +9 -33
  78. package/docs/UserLocation.md +10 -2
  79. package/docs/docs.json +16 -31
  80. package/javascript/Maplibre.ts +5 -1
  81. package/javascript/components/BackgroundLayer.tsx +27 -20
  82. package/javascript/components/Callout.tsx +40 -40
  83. package/javascript/components/Camera.tsx +421 -478
  84. package/javascript/components/CircleLayer.tsx +29 -22
  85. package/javascript/components/FillExtrusionLayer.tsx +23 -23
  86. package/javascript/components/FillLayer.tsx +22 -19
  87. package/javascript/components/HeatmapLayer.tsx +21 -19
  88. package/javascript/components/ImageSource.tsx +25 -32
  89. package/javascript/components/Images.tsx +36 -35
  90. package/javascript/components/Light.tsx +20 -47
  91. package/javascript/components/LineLayer.tsx +23 -20
  92. package/javascript/components/MapView.tsx +604 -554
  93. package/javascript/components/MarkerView.tsx +23 -38
  94. package/javascript/components/NativeUserLocation.tsx +3 -5
  95. package/javascript/components/PointAnnotation.tsx +111 -87
  96. package/javascript/components/RasterLayer.tsx +21 -18
  97. package/javascript/components/RasterSource.tsx +39 -42
  98. package/javascript/components/ShapeSource.tsx +287 -239
  99. package/javascript/components/Style.tsx +1 -1
  100. package/javascript/components/SymbolLayer.tsx +34 -28
  101. package/javascript/components/UserLocation.tsx +164 -151
  102. package/javascript/components/VectorSource.tsx +128 -117
  103. package/javascript/components/annotations/Annotation.tsx +105 -79
  104. package/javascript/{components/AbstractLayer.tsx → hooks/useAbstractLayer.ts} +54 -37
  105. package/javascript/hooks/useAbstractSource.ts +34 -0
  106. package/javascript/hooks/useNativeBridge.ts +125 -0
  107. package/javascript/hooks/useNativeRef.ts +13 -0
  108. package/javascript/hooks/useOnce.ts +12 -0
  109. package/javascript/utils/Logger.ts +3 -3
  110. package/package.json +2 -1
  111. package/scripts/templates/RCTMLNStyleFactory.java.ejs +14 -14
  112. package/javascript/components/AbstractSource.tsx +0 -27
  113. package/javascript/components/NativeBridgeComponent.tsx +0 -117
@@ -16,13 +16,13 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
16
16
  import com.facebook.react.bridge.ReactMethod;
17
17
  import com.facebook.react.bridge.ReadableMap;
18
18
  import com.facebook.react.module.annotations.ReactModule;
19
- import com.mapbox.geojson.Feature;
20
- import com.mapbox.geojson.FeatureCollection;
21
- import com.mapbox.geojson.Point;
22
- import com.mapbox.mapboxsdk.camera.CameraPosition;
23
- import com.mapbox.mapboxsdk.snapshotter.MapSnapshot;
24
- import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter;
25
- import com.mapbox.mapboxsdk.storage.FileSource;
19
+ import org.maplibre.geojson.Feature;
20
+ import org.maplibre.geojson.FeatureCollection;
21
+ import org.maplibre.geojson.Point;
22
+ import org.maplibre.android.camera.CameraPosition;
23
+ import org.maplibre.android.snapshotter.MapSnapshot;
24
+ import org.maplibre.android.snapshotter.MapSnapshotter;
25
+ import org.maplibre.android.storage.FileSource;
26
26
  import com.maplibre.rctmln.utils.BitmapUtils;
27
27
  import com.maplibre.rctmln.utils.GeoJSONUtils;
28
28
 
@@ -1,6 +1,6 @@
1
1
  package com.maplibre.rctmln.utils;
2
2
 
3
- import com.mapbox.mapboxsdk.style.expressions.Expression;
3
+ import org.maplibre.android.style.expressions.Expression;
4
4
 
5
5
  public class ClusterPropertyEntry {
6
6
  public Expression operator;
@@ -20,8 +20,8 @@ import com.facebook.imagepipeline.image.CloseableStaticBitmap;
20
20
  import com.facebook.imagepipeline.request.ImageRequest;
21
21
  import com.facebook.imagepipeline.request.ImageRequestBuilder;
22
22
  import com.facebook.react.views.imagehelper.ImageSource;
23
- import com.mapbox.mapboxsdk.maps.MapboxMap;
24
- import com.mapbox.mapboxsdk.maps.Style;
23
+ import org.maplibre.android.maps.MapLibreMap;
24
+ import org.maplibre.android.maps.Style;
25
25
 
26
26
  import java.io.File;
27
27
  import java.lang.ref.WeakReference;
@@ -41,12 +41,12 @@ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry
41
41
  public static final String LOG_TAG = "DownloadMapImageTask";
42
42
 
43
43
  private WeakReference<Context> mContext;
44
- private WeakReference<MapboxMap> mMap;
44
+ private WeakReference<MapLibreMap> mMap;
45
45
  @Nullable
46
46
  private OnAllImagesLoaded mCallback;
47
47
  private final Object mCallerContext;
48
48
 
49
- public DownloadMapImageTask(Context context, MapboxMap map, @Nullable OnAllImagesLoaded callback) {
49
+ public DownloadMapImageTask(Context context, MapLibreMap map, @Nullable OnAllImagesLoaded callback) {
50
50
  mContext = new WeakReference<>(context.getApplicationContext());
51
51
  mMap = new WeakReference<>(map);
52
52
  mCallback = callback;
@@ -130,7 +130,7 @@ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry
130
130
 
131
131
  @Override
132
132
  protected void onPostExecute(List<Map.Entry<String, Bitmap>> images) {
133
- MapboxMap map = mMap.get();
133
+ MapLibreMap map = mMap.get();
134
134
  if (map != null && images != null && images.size() > 0) {
135
135
  Style style = map.getStyle();
136
136
  if (style != null) {
@@ -4,8 +4,8 @@ import com.facebook.react.bridge.Dynamic;
4
4
  import com.facebook.react.bridge.ReadableArray;
5
5
  import com.facebook.react.bridge.ReadableMap;
6
6
  import com.google.gson.JsonArray;
7
- import com.mapbox.mapboxsdk.style.expressions.Expression;
8
- import com.mapbox.mapboxsdk.style.expressions.Expression.Converter;
7
+ import org.maplibre.android.style.expressions.Expression;
8
+ import org.maplibre.android.style.expressions.Expression.Converter;
9
9
 
10
10
  import org.json.JSONArray;
11
11
 
@@ -6,19 +6,19 @@ import com.facebook.react.bridge.WritableArray;
6
6
  import com.facebook.react.bridge.WritableMap;
7
7
  import com.facebook.react.bridge.WritableNativeArray;
8
8
  import com.facebook.react.bridge.WritableNativeMap;
9
- import com.mapbox.geojson.Feature;
10
- import com.mapbox.geojson.FeatureCollection;
11
- import com.mapbox.geojson.Geometry;
12
- import com.mapbox.geojson.GeometryCollection;
13
- import com.mapbox.geojson.LineString;
14
- import com.mapbox.geojson.MultiPoint;
15
- import com.mapbox.geojson.Point;
16
- import com.mapbox.geojson.Polygon;
17
- import com.mapbox.mapboxsdk.geometry.LatLng;
18
- import com.mapbox.mapboxsdk.geometry.LatLngBounds;
19
- import com.mapbox.mapboxsdk.geometry.LatLngQuad;
20
- import com.mapbox.mapboxsdk.style.light.Position;
21
- import com.mapbox.turf.TurfMeasurement;
9
+ import org.maplibre.geojson.Feature;
10
+ import org.maplibre.geojson.FeatureCollection;
11
+ import org.maplibre.geojson.Geometry;
12
+ import org.maplibre.geojson.GeometryCollection;
13
+ import org.maplibre.geojson.LineString;
14
+ import org.maplibre.geojson.MultiPoint;
15
+ import org.maplibre.geojson.Point;
16
+ import org.maplibre.geojson.Polygon;
17
+ import org.maplibre.android.geometry.LatLng;
18
+ import org.maplibre.android.geometry.LatLngBounds;
19
+ import org.maplibre.android.geometry.LatLngQuad;
20
+ import org.maplibre.android.style.light.Position;
21
+ import org.maplibre.turf.TurfMeasurement;
22
22
 
23
23
  import java.util.ArrayList;
24
24
  import java.util.List;
@@ -2,9 +2,9 @@ package com.maplibre.rctmln.utils;
2
2
 
3
3
  import android.graphics.PointF;
4
4
 
5
- import com.mapbox.mapboxsdk.geometry.LatLng;
6
- import com.mapbox.mapboxsdk.geometry.LatLngBounds;
7
- import com.mapbox.mapboxsdk.geometry.VisibleRegion;
5
+ import org.maplibre.android.geometry.LatLng;
6
+ import org.maplibre.android.geometry.LatLngBounds;
7
+ import org.maplibre.android.geometry.VisibleRegion;
8
8
 
9
9
  /**
10
10
  * Created by nickitaliano on 1/5/18.
@@ -1,6 +1,6 @@
1
1
  package com.maplibre.rctmln.utils;
2
2
 
3
- import com.mapbox.mapboxsdk.maps.MapboxMap;
3
+ import org.maplibre.android.maps.MapLibreMap;
4
4
 
5
5
  import com.maplibre.rctmln.components.AbstractEventEmitter;
6
6
  import com.maplibre.rctmln.events.IEvent;
@@ -9,7 +9,7 @@ import com.maplibre.rctmln.events.IEvent;
9
9
  * Created by nickitaliano on 8/31/17.
10
10
  */
11
11
 
12
- public class SimpleEventCallback implements MapboxMap.CancelableCallback {
12
+ public class SimpleEventCallback implements MapLibreMap.CancelableCallback {
13
13
  private AbstractEventEmitter mEventEmitter;
14
14
  private IEvent mEvent;
15
15
 
@@ -3,7 +3,7 @@ package com.maplibre.rctmln.utils;
3
3
  import android.graphics.Point;
4
4
  import android.graphics.PointF;
5
5
 
6
- import com.mapbox.mapboxsdk.geometry.LatLng;
6
+ import org.maplibre.android.geometry.LatLng;
7
7
 
8
8
  import java.util.ArrayList;
9
9
  import java.util.HashMap;
package/docs/Camera.md CHANGED
@@ -34,9 +34,9 @@ Map camera transitions to fit provided bounds
34
34
  ##### arguments
35
35
  | Name | Type | Required | Description |
36
36
  | ---- | :--: | :------: | :----------: |
37
- | `northEastCoordinates` | `Array` | `Yes` | North east coordinate of bound |
38
- | `southWestCoordinates` | `Array` | `Yes` | South west coordinate of bound |
39
- | `padding` | `n/a` | `No` | Padding for the bounds |
37
+ | `northEastCoordinates` | `GeoJSON.Position` | `Yes` | North east coordinate of bound |
38
+ | `southWestCoordinates` | `GeoJSON.Position` | `Yes` | South west coordinate of bound |
39
+ | `padding` | `Number \| Array` | `No` | Padding for the bounds |
40
40
  | `animationDuration` | `Number` | `No` | Duration of camera animation |
41
41
 
42
42
 
package/docs/MapView.md CHANGED
@@ -16,40 +16,16 @@
16
16
  | pitchEnabled | `boolean` | `true` | `false` | Enable/Disable pitch on map |
17
17
  | rotateEnabled | `boolean` | `true` | `false` | Enable/Disable rotation on map |
18
18
  | attributionEnabled | `boolean` | `true` | `false` | Enable/Disable attribution on map.<br/><br/>This must be enabled for Mapbox-hosted tiles and styles. Please refer to the Mapbox Terms of Service.<br/>Other providers do not require this. |
19
- | attributionPosition | `\| {
20
- top?: number;
21
- left?: number;
22
- }
23
- \| {
24
- top?: number;
25
- right?: number;
26
- }
27
- \| {
28
- bottom?: number;
29
- left?: number;
30
- }
31
- \| {
32
- bottom?: number;
33
- right?: number;
34
- }` | `none` | `false` | Adds attribution offset, e.g. `{top: 8, left: 8}` will put attribution button in top-left corner of the map |
19
+ | attributionPosition | `\| {top?: number; left?: number}
20
+ \| {top?: number; right?: number}
21
+ \| {bottom?: number; left?: number}
22
+ \| {bottom?: number; right?: number}` | `none` | `false` | Adds attribution offset, e.g. `{top: 8, left: 8}` will put attribution button in top-left corner of the map |
35
23
  | tintColor | `string \| unknown[]` | `none` | `false` | MapView's tintColor |
36
24
  | logoEnabled | `boolean` | `false` | `false` | Enable/Disable the logo on the map. |
37
- | logoPosition | `\| {
38
- top?: number;
39
- left?: number;
40
- }
41
- \| {
42
- top?: number;
43
- right?: number;
44
- }
45
- \| {
46
- bottom?: number;
47
- left?: number;
48
- }
49
- \| {
50
- bottom?: number;
51
- right?: number;
52
- }` | `none` | `false` | Adds logo offset, e.g. `{top: 8, left: 8}` will put the logo in top-left corner of the map |
25
+ | logoPosition | `\| {top?: number; left?: number}
26
+ \| {top?: number; right?: number}
27
+ \| {bottom?: number; left?: number}
28
+ \| {bottom?: number; right?: number}` | `none` | `false` | Adds logo offset, e.g. `{top: 8, left: 8}` will put the logo in top-left corner of the map |
53
29
  | compassEnabled | `boolean` | `none` | `false` | Enable/Disable the compass from appearing on the map |
54
30
  | compassViewPosition | `number` | `none` | `false` | Change corner of map the compass starts at. 0: TopLeft, 1: TopRight, 2: BottomLeft, 3: BottomRight |
55
31
  | compassViewMargins | `object` | `none` | `false` | Add margins to the compass with x and y values |
@@ -115,7 +91,7 @@ Returns an array of rendered map features that intersect with a given point.
115
91
  ##### arguments
116
92
  | Name | Type | Required | Description |
117
93
  | ---- | :--: | :------: | :----------: |
118
- | `point` | `tuple` | `Yes` | A point expressed in the map view’s coordinate system. |
94
+ | `point` | `tuple` | `Yes` | undefined |
119
95
  | `filter` | `FilterExpression` | `No` | A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array. |
120
96
  | `layerIDs` | `Array` | `No` | A array of layer id's to filter the features by |
121
97
 
@@ -14,14 +14,22 @@
14
14
  | children | `ReactElement \| ReactElement[]` | `none` | `false` | Custom location icon of type mapbox-gl-native components<br/><br/>NOTE: Forking maintainer does not understand the above comment. |
15
15
 
16
16
  ### methods
17
- #### setLocationManager({running}: {running: boolean})
17
+ #### setLocationManager({
18
+ running,
19
+ }: {
20
+ running: boolean;
21
+ })
18
22
 
19
23
  Whether to start or stop listening to the locationManager<br/><br/>Notice, that listening will start automatically when<br/>either `onUpdate` or `visible` are set
20
24
 
21
25
  ##### arguments
22
26
  | Name | Type | Required | Description |
23
27
  | ---- | :--: | :------: | :----------: |
24
- | `{running}: {running: boolean}` | `{running:boolean}` | `Yes` | undefined |
28
+ | `{
29
+ running,
30
+ }: {
31
+ running: boolean;
32
+ }` | `{running:boolean;}` | `Yes` | undefined |
25
33
 
26
34
 
27
35
  #### needsLocationManagerRunning()
package/docs/docs.json CHANGED
@@ -25,24 +25,9 @@
25
25
  {
26
26
  "name": "symbolStyle",
27
27
  "docblock": null,
28
- "modifiers": [
29
- "get"
30
- ],
28
+ "modifiers": [],
31
29
  "params": [],
32
- "returns": {
33
- "type": {
34
- "name": "union",
35
- "raw": "SymbolLayerStyleProps | undefined",
36
- "elements": [
37
- {
38
- "name": "SymbolLayerStyleProps"
39
- },
40
- {
41
- "name": "undefined"
42
- }
43
- ]
44
- }
45
- }
30
+ "returns": null
46
31
  }
47
32
  ],
48
33
  "props": [
@@ -268,14 +253,14 @@
268
253
  "methods": [
269
254
  {
270
255
  "name": "fitBounds",
271
- "docblock": "Map camera transitions to fit provided bounds\n\n@example\nthis.camera.fitBounds([lng, lat], [lng, lat])\nthis.camera.fitBounds([lng, lat], [lng, lat], 20, 1000) // padding for all sides\nthis.camera.fitBounds([lng, lat], [lng, lat], [verticalPadding, horizontalPadding], 1000)\nthis.camera.fitBounds([lng, lat], [lng, lat], [top, right, bottom, left], 1000)\n\n@param {Array<Number>} northEastCoordinates - North east coordinate of bound\n@param {Array<Number>} southWestCoordinates - South west coordinate of bound\n@param {Number|Array<Number>=} padding - Padding for the bounds\n@param {Number=} animationDuration - Duration of camera animation\n@return {void}",
256
+ "docblock": "Map camera transitions to fit provided bounds\n\n@example\nthis.camera.fitBounds([lng, lat], [lng, lat])\nthis.camera.fitBounds([lng, lat], [lng, lat], 20, 1000) // padding for all sides\nthis.camera.fitBounds([lng, lat], [lng, lat], [verticalPadding, horizontalPadding], 1000)\nthis.camera.fitBounds([lng, lat], [lng, lat], [top, right, bottom, left], 1000)\n\n@param {Array<Number>} northEastCoordinates - North east coordinate of bound\n@param {Array<Number>} southWestCoordinates - South west coordinate of bound\n@param {Number|Array<Number>|undefined} padding - Padding for the bounds\n@param {Number=} animationDuration - Duration of camera animation\n@return {void}",
272
257
  "modifiers": [],
273
258
  "params": [
274
259
  {
275
260
  "name": "northEastCoordinates",
276
261
  "description": "North east coordinate of bound",
277
262
  "type": {
278
- "name": "Array"
263
+ "name": "GeoJSON.Position"
279
264
  },
280
265
  "optional": false
281
266
  },
@@ -283,7 +268,7 @@
283
268
  "name": "southWestCoordinates",
284
269
  "description": "South west coordinate of bound",
285
270
  "type": {
286
- "name": "Array"
271
+ "name": "GeoJSON.Position"
287
272
  },
288
273
  "optional": false
289
274
  },
@@ -291,7 +276,7 @@
291
276
  "name": "padding",
292
277
  "description": "Padding for the bounds",
293
278
  "type": {
294
- "name": null
279
+ "name": "Number \\| Array"
295
280
  },
296
281
  "optional": true
297
282
  },
@@ -1586,7 +1571,8 @@
1586
1571
  }
1587
1572
  ],
1588
1573
  "composes": [
1589
- "BaseProps"
1574
+ "BaseProps",
1575
+ "BaseLayerProps"
1590
1576
  ],
1591
1577
  "fileNameWithExt": "Light.tsx",
1592
1578
  "name": "Light",
@@ -2136,7 +2122,7 @@
2136
2122
  },
2137
2123
  {
2138
2124
  "name": "getVisibleBounds",
2139
- "docblock": "The coordinate bounds(ne, sw) visible in the users’s viewport.\n\n@example\nconst visibleBounds = await this._map.getVisibleBounds();\n\n@return {VisibleBounds}",
2125
+ "docblock": "The coordinate bounds(ne, sw) visible in the users’s viewport.\n\n@example\nconst visibleBounds = await this._map.getVisibleBounds();\n\n@return {Array}",
2140
2126
  "modifiers": [
2141
2127
  "async"
2142
2128
  ],
@@ -2169,18 +2155,17 @@
2169
2155
  },
2170
2156
  {
2171
2157
  "name": "queryRenderedFeaturesAtPoint",
2172
- "docblock": "Returns an array of rendered map features that intersect with a given point.\n\n@example\nthis._map.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])\n\n@typedef {number} ScreenPointX\n@typedef {number} ScreenPointY\n@param {[ScreenPointX, ScreenPointY]} point - A point expressed in the map view’s coordinate system.\n@param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.\n@param {Array=} layerIDs - A array of layer id's to filter the features by\n@return {GeoJSON.FeatureCollection}",
2158
+ "docblock": "Returns an array of rendered map features that intersect with a given point.\n\n@example\nthis._map.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])\n\n@param {Array<Number>} coordinate - A point expressed in the map view’s coordinate system.\n@param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.\n@param {Array=} layerIDs - A array of layer id's to filter the features by\n@return {GeoJSON.FeatureCollection}",
2173
2159
  "modifiers": [
2174
2160
  "async"
2175
2161
  ],
2176
2162
  "params": [
2177
2163
  {
2178
2164
  "name": "point",
2179
- "description": "A point expressed in the map view’s coordinate system.",
2165
+ "optional": false,
2180
2166
  "type": {
2181
2167
  "name": "tuple"
2182
- },
2183
- "optional": false
2168
+ }
2184
2169
  },
2185
2170
  {
2186
2171
  "name": "filter",
@@ -2500,7 +2485,7 @@
2500
2485
  {
2501
2486
  "name": "attributionPosition",
2502
2487
  "required": false,
2503
- "type": "\\| {\n top?: number;\n left?: number;\n }\n\\| {\n top?: number;\n right?: number;\n }\n\\| {\n bottom?: number;\n left?: number;\n }\n\\| {\n bottom?: number;\n right?: number;\n }",
2488
+ "type": "\\| {top?: number; left?: number}\n\\| {top?: number; right?: number}\n\\| {bottom?: number; left?: number}\n\\| {bottom?: number; right?: number}",
2504
2489
  "default": "none",
2505
2490
  "description": "Adds attribution offset, e.g. `{top: 8, left: 8}` will put attribution button in top-left corner of the map"
2506
2491
  },
@@ -2521,7 +2506,7 @@
2521
2506
  {
2522
2507
  "name": "logoPosition",
2523
2508
  "required": false,
2524
- "type": "\\| {\n top?: number;\n left?: number;\n }\n\\| {\n top?: number;\n right?: number;\n }\n\\| {\n bottom?: number;\n left?: number;\n }\n\\| {\n bottom?: number;\n right?: number;\n }",
2509
+ "type": "\\| {top?: number; left?: number}\n\\| {top?: number; right?: number}\n\\| {bottom?: number; left?: number}\n\\| {bottom?: number; right?: number}",
2525
2510
  "default": "none",
2526
2511
  "description": "Adds logo offset, e.g. `{top: 8, left: 8}` will put the logo in top-left corner of the map"
2527
2512
  },
@@ -4778,10 +4763,10 @@
4778
4763
  ],
4779
4764
  "params": [
4780
4765
  {
4781
- "name": "{running}: {running: boolean}",
4766
+ "name": "{\n running,\n}: {\n running: boolean;\n}",
4782
4767
  "optional": false,
4783
4768
  "type": {
4784
- "name": "{running:boolean}"
4769
+ "name": "{running:boolean;}"
4785
4770
  }
4786
4771
  }
4787
4772
  ],
@@ -5,10 +5,12 @@ export {
5
5
  type CameraPadding,
6
6
  type CameraAnimationMode,
7
7
  type CameraBounds,
8
+ type CameraRef,
8
9
  } from './components/Camera';
9
- export {default as MapView, type MapViewState} from './components/MapView';
10
+ export {default as MapView, type MapViewRef} from './components/MapView';
10
11
  export {default as Light} from './components/Light';
11
12
  export {default as PointAnnotation} from './components/PointAnnotation';
13
+ export type {PointAnnotationRef} from './components/PointAnnotation';
12
14
  export {default as Annotation} from './components/annotations/Annotation';
13
15
  export {default as Callout} from './components/Callout';
14
16
  export {requestAndroidLocationPermissions} from './requestAndroidLocationPermissions';
@@ -16,8 +18,10 @@ export {
16
18
  default as UserLocation,
17
19
  UserLocationRenderMode,
18
20
  } from './components/UserLocation';
21
+ export type {UserLocationRef} from './components/UserLocation';
19
22
  export {default as VectorSource} from './components/VectorSource';
20
23
  export {default as ShapeSource} from './components/ShapeSource';
24
+ export type {ShapeSourceRef} from './components/ShapeSource';
21
25
  export {default as RasterSource} from './components/RasterSource';
22
26
  export {default as ImageSource} from './components/ImageSource';
23
27
  export {default as Images} from './components/Images';
@@ -1,16 +1,18 @@
1
1
  import {BackgroundLayerStyleProps} from '../utils/MaplibreStyles';
2
2
  import BaseProps from '../types/BaseProps';
3
+ import useAbstractLayer, {
4
+ BaseLayerProps,
5
+ NativeBaseProps,
6
+ } from '../hooks/useAbstractLayer';
3
7
 
4
- import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
-
6
- import React, {ReactNode} from 'react';
8
+ import React from 'react';
7
9
  import {NativeModules, requireNativeComponent} from 'react-native';
8
10
 
9
11
  const MapLibreGL = NativeModules.MLNModule;
10
12
 
11
13
  export const NATIVE_MODULE_NAME = 'RCTMLNBackgroundLayer';
12
14
 
13
- interface BackgroundLayerProps extends BaseProps, BaseLayerProps {
15
+ export interface BackgroundLayerProps extends BaseProps, BaseLayerProps {
14
16
  /**
15
17
  * Customizable style attributes
16
18
  */
@@ -21,23 +23,28 @@ interface NativeProps
21
23
  extends Omit<BackgroundLayerProps, 'style'>,
22
24
  NativeBaseProps {}
23
25
 
24
- class BackgroundLayer extends AbstractLayer<BackgroundLayerProps, NativeProps> {
25
- static defaultProps = {
26
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
27
- };
28
-
29
- render(): ReactNode {
30
- return (
31
- <RCTMLNBackgroundLayer
32
- testID="rctmlnBackgroundLayer"
33
- ref={this.setNativeLayer}
34
- {...this.baseProps}
35
- />
36
- );
37
- }
38
- }
39
-
40
26
  const RCTMLNBackgroundLayer =
41
27
  requireNativeComponent<BackgroundLayerProps>(NATIVE_MODULE_NAME);
42
28
 
29
+ const BackgroundLayer: React.FC<BackgroundLayerProps> = ({
30
+ sourceID = MapLibreGL.StyleSource.DefaultSourceID,
31
+ ...props
32
+ }: BackgroundLayerProps) => {
33
+ const {baseProps, setNativeLayer} = useAbstractLayer<
34
+ BackgroundLayerProps,
35
+ NativeProps
36
+ >({
37
+ ...props,
38
+ sourceID,
39
+ });
40
+
41
+ return (
42
+ <RCTMLNBackgroundLayer
43
+ testID="rctmlnBackgroundLayer"
44
+ ref={setNativeLayer}
45
+ {...baseProps}
46
+ />
47
+ );
48
+ };
49
+
43
50
  export default BackgroundLayer;
@@ -82,59 +82,59 @@ interface NativeProps extends Omit<CalloutProps, 'style'> {
82
82
  /**
83
83
  * Callout that displays information about a selected annotation near the annotation.
84
84
  */
85
- class Callout extends React.PureComponent<CalloutProps> {
86
- get _containerStyle(): ViewStyle[] {
87
- const style = [
88
- {
89
- position: 'absolute',
90
- zIndex: 999,
91
- backgroundColor: 'transparent',
92
- } as ViewStyle,
93
- ];
85
+ const Callout = (props: CalloutProps): ReactElement => {
86
+ const {
87
+ title,
88
+ style,
89
+ containerStyle,
90
+ contentStyle,
91
+ tipStyle,
92
+ textStyle,
93
+ children,
94
+ } = props;
94
95
 
95
- if (this.props.containerStyle) {
96
- style.push(this.props.containerStyle);
97
- }
96
+ const _containerStyle: ViewStyle[] = [
97
+ {
98
+ position: 'absolute',
99
+ zIndex: 999,
100
+ backgroundColor: 'transparent',
101
+ ...containerStyle,
102
+ } as ViewStyle,
103
+ ];
98
104
 
99
- return style;
100
- }
105
+ const _hasChildren = React.Children.count(children) > 0;
101
106
 
102
- get _hasChildren(): boolean {
103
- return React.Children.count(this.props.children) > 0;
104
- }
105
-
106
- _renderDefaultCallout(): ReactElement {
107
+ const _renderDefaultCallout = (): ReactElement => {
107
108
  return (
108
- <Animated.View style={[styles.container, this.props.style]}>
109
- <View style={[styles.content, this.props.contentStyle]}>
110
- <Text style={[styles.title, this.props.textStyle]}>
111
- {this.props.title}
109
+ <Animated.View testID="container" style={[styles.container, style]}>
110
+ <View testID="wrapper" style={[styles.content, contentStyle]}>
111
+ <Text testID="title" style={[styles.title, textStyle]}>
112
+ {title}
112
113
  </Text>
113
114
  </View>
114
- <View style={[styles.tip, this.props.tipStyle]} />
115
+ <View testID="tip" style={[styles.tip, tipStyle]} />
115
116
  </Animated.View>
116
117
  );
117
- }
118
+ };
118
119
 
119
- _renderCustomCallout(): ReactElement {
120
+ const _renderCustomCallout = (): ReactElement => {
120
121
  return (
121
- <Animated.View {...this.props} style={this.props.style}>
122
- {this.props.children}
122
+ <Animated.View testID="container" {...props} style={style}>
123
+ {children}
123
124
  </Animated.View>
124
125
  );
125
- }
126
+ };
126
127
 
127
- render(): ReactElement {
128
- const calloutContent = this._hasChildren
129
- ? this._renderCustomCallout()
130
- : this._renderDefaultCallout();
131
- return (
132
- <RCTMLNCallout style={this._containerStyle}>
133
- {calloutContent}
134
- </RCTMLNCallout>
135
- );
136
- }
137
- }
128
+ const calloutContent = _hasChildren
129
+ ? _renderCustomCallout()
130
+ : _renderDefaultCallout();
131
+
132
+ return (
133
+ <RCTMLNCallout testID="callout" style={_containerStyle}>
134
+ {calloutContent}
135
+ </RCTMLNCallout>
136
+ );
137
+ };
138
138
 
139
139
  const RCTMLNCallout = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
140
140