@maplibre/maplibre-react-native 10.0.0-alpha.5 → 10.0.0-alpha.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.
- package/.eslintrc.js +3 -1
- package/.yarn/sdks/eslint/bin/eslint.js +8 -1
- package/.yarn/sdks/eslint/lib/api.js +8 -1
- package/.yarn/sdks/eslint/lib/unsupported-api.js +8 -1
- package/.yarn/sdks/prettier/bin/prettier.cjs +8 -1
- package/.yarn/sdks/prettier/index.cjs +8 -1
- package/.yarn/sdks/typescript/bin/tsc +8 -1
- package/.yarn/sdks/typescript/bin/tsserver +8 -1
- package/.yarn/sdks/typescript/lib/tsc.js +8 -1
- package/.yarn/sdks/typescript/lib/tsserver.js +20 -6
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +20 -6
- package/.yarn/sdks/typescript/lib/typescript.js +8 -1
- package/CHANGELOG.md +57 -48
- package/CONTRIBUTING.md +10 -9
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerViewManager.java +5 -3
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapView.java +7 -7
- package/docs/Camera.md +3 -3
- package/docs/MapView.md +9 -33
- package/docs/UserLocation.md +10 -2
- package/docs/docs.json +17 -32
- package/docs/offlineManager.md +246 -0
- package/javascript/Maplibre.ts +5 -1
- package/javascript/components/BackgroundLayer.tsx +27 -20
- package/javascript/components/Callout.tsx +40 -40
- package/javascript/components/Camera.tsx +421 -478
- package/javascript/components/CircleLayer.tsx +29 -22
- package/javascript/components/FillExtrusionLayer.tsx +23 -23
- package/javascript/components/FillLayer.tsx +22 -19
- package/javascript/components/HeatmapLayer.tsx +21 -19
- package/javascript/components/ImageSource.tsx +25 -32
- package/javascript/components/Images.tsx +36 -35
- package/javascript/components/Light.tsx +20 -47
- package/javascript/components/LineLayer.tsx +23 -20
- package/javascript/components/MapView.tsx +604 -554
- package/javascript/components/MarkerView.tsx +23 -38
- package/javascript/components/NativeUserLocation.tsx +3 -5
- package/javascript/components/PointAnnotation.tsx +111 -87
- package/javascript/components/RasterLayer.tsx +21 -18
- package/javascript/components/RasterSource.tsx +39 -42
- package/javascript/components/ShapeSource.tsx +287 -239
- package/javascript/components/Style.tsx +1 -1
- package/javascript/components/SymbolLayer.tsx +34 -28
- package/javascript/components/UserLocation.tsx +164 -151
- package/javascript/components/VectorSource.tsx +128 -117
- package/javascript/components/annotations/Annotation.tsx +105 -79
- package/javascript/{components/AbstractLayer.tsx → hooks/useAbstractLayer.ts} +54 -37
- package/javascript/hooks/useAbstractSource.ts +34 -0
- package/javascript/hooks/useNativeBridge.ts +125 -0
- package/javascript/hooks/useNativeRef.ts +13 -0
- package/javascript/hooks/useOnce.ts +12 -0
- package/javascript/utils/Logger.ts +3 -3
- package/package.json +2 -1
- package/javascript/components/AbstractSource.tsx +0 -27
- package/javascript/components/NativeBridgeComponent.tsx +0 -117
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
39
|
-
|
|
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` |
|
|
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
|
|
package/docs/UserLocation.md
CHANGED
|
@@ -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({
|
|
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
|
-
| `{
|
|
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
|
|
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": "
|
|
263
|
+
"name": "GeoJSON.Position"
|
|
279
264
|
},
|
|
280
265
|
"optional": false
|
|
281
266
|
},
|
|
@@ -283,15 +268,15 @@
|
|
|
283
268
|
"name": "southWestCoordinates",
|
|
284
269
|
"description": "South west coordinate of bound",
|
|
285
270
|
"type": {
|
|
286
|
-
"name": "
|
|
271
|
+
"name": "GeoJSON.Position"
|
|
287
272
|
},
|
|
288
273
|
"optional": false
|
|
289
274
|
},
|
|
290
275
|
{
|
|
291
276
|
"name": "padding",
|
|
292
|
-
"description": "
|
|
277
|
+
"description": "Padding for the bounds",
|
|
293
278
|
"type": {
|
|
294
|
-
"name": "Number"
|
|
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 {
|
|
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@
|
|
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
|
-
"
|
|
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": "\\| {
|
|
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": "\\| {
|
|
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
|
],
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<!-- This file was autogenerated from offlineManager.js do not modify -->
|
|
2
|
+
## <MapLibreGL.offlineManager />
|
|
3
|
+
### OfflineManager implements a singleton (shared object) that manages offline packs.<br/>All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.<br/>The shared object maintains a canonical collection of offline packs.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### methods
|
|
7
|
+
#### createPack(options[, progressListener][, errorListener])
|
|
8
|
+
|
|
9
|
+
Creates and registers an offline pack that downloads the resources needed to use the given region offline.
|
|
10
|
+
|
|
11
|
+
##### arguments
|
|
12
|
+
| Name | Type | Required | Description |
|
|
13
|
+
| ---- | :--: | :------: | :----------: |
|
|
14
|
+
| `options` | `OfflineCreatePackOptions` | `Yes` | Create options for a offline pack that specifices zoom levels, style url, and the region to download. |
|
|
15
|
+
| `progressListener` | `Callback` | `No` | Callback that listens for status events while downloading the offline resource. |
|
|
16
|
+
| `errorListener` | `Callback` | `No` | Callback that listens for status events while downloading the offline resource. |
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
const progressListener = (offlineRegion, status) => console.log(offlineRegion, status);
|
|
22
|
+
const errorListener = (offlineRegion, err) => console.log(offlineRegion, err);
|
|
23
|
+
|
|
24
|
+
await MapLibreGL.offlineManager.createPack({
|
|
25
|
+
name: 'offlinePack',
|
|
26
|
+
styleURL: 'mapbox://...',
|
|
27
|
+
minZoom: 14,
|
|
28
|
+
maxZoom: 20,
|
|
29
|
+
bounds: [[neLng, neLat], [swLng, swLat]]
|
|
30
|
+
}, progressListener, errorListener)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#### invalidatePack(name)
|
|
35
|
+
|
|
36
|
+
Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated.This is more efficient than deleting the offline pack and downloading it again. If the data stored locally matches that on the server, new data will not be downloaded.
|
|
37
|
+
|
|
38
|
+
##### arguments
|
|
39
|
+
| Name | Type | Required | Description |
|
|
40
|
+
| ---- | :--: | :------: | :----------: |
|
|
41
|
+
| `name` | `String` | `Yes` | Name of the offline pack. |
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
await MapLibreGL.offlineManager.invalidatePack('packName')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
#### deletePack(name)
|
|
51
|
+
|
|
52
|
+
Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
|
|
53
|
+
|
|
54
|
+
##### arguments
|
|
55
|
+
| Name | Type | Required | Description |
|
|
56
|
+
| ---- | :--: | :------: | :----------: |
|
|
57
|
+
| `name` | `String` | `Yes` | Name of the offline pack. |
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
await MapLibreGL.offlineManager.deletePack('packName')
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
#### invalidateAmbientCache()
|
|
67
|
+
|
|
68
|
+
Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.<br/>This is the recommend method for clearing the cache.<br/>This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.<br/>It does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects.
|
|
69
|
+
|
|
70
|
+
##### arguments
|
|
71
|
+
| Name | Type | Required | Description |
|
|
72
|
+
| ---- | :--: | :------: | :----------: |
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
await MapLibreGL.offlineManager.invalidateAmbientCache();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
#### clearAmbientCache()
|
|
83
|
+
|
|
84
|
+
Erases resources from the ambient cache.<br/>This method clears the cache and decreases the amount of space that map resources take up on the device.
|
|
85
|
+
|
|
86
|
+
##### arguments
|
|
87
|
+
| Name | Type | Required | Description |
|
|
88
|
+
| ---- | :--: | :------: | :----------: |
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
await MapLibreGL.offlineManager.clearAmbientCache();
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
#### setMaximumAmbientCacheSize(size)
|
|
99
|
+
|
|
100
|
+
Sets the maximum size of the ambient cache in bytes. Disables the ambient cache if set to 0.<br/>This method may be computationally expensive because it will erase resources from the ambient cache if its size is decreased.
|
|
101
|
+
|
|
102
|
+
##### arguments
|
|
103
|
+
| Name | Type | Required | Description |
|
|
104
|
+
| ---- | :--: | :------: | :----------: |
|
|
105
|
+
| `size` | `Number` | `Yes` | Size of ambient cache. |
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
await MapLibreGL.offlineManager.setMaximumAmbientCacheSize(5000000);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
#### resetDatabase()
|
|
115
|
+
|
|
116
|
+
Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
|
|
117
|
+
|
|
118
|
+
##### arguments
|
|
119
|
+
| Name | Type | Required | Description |
|
|
120
|
+
| ---- | :--: | :------: | :----------: |
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
await MapLibreGL.offlineManager.resetDatabase();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
#### getPacks()
|
|
131
|
+
|
|
132
|
+
Retrieves all the current offline packs that are stored in the database.
|
|
133
|
+
|
|
134
|
+
##### arguments
|
|
135
|
+
| Name | Type | Required | Description |
|
|
136
|
+
| ---- | :--: | :------: | :----------: |
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
const offlinePacks = await MapLibreGL.offlineManager.getPacks();
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
#### getPack(name)
|
|
147
|
+
|
|
148
|
+
Retrieves an offline pack that is stored in the database by name.
|
|
149
|
+
|
|
150
|
+
##### arguments
|
|
151
|
+
| Name | Type | Required | Description |
|
|
152
|
+
| ---- | :--: | :------: | :----------: |
|
|
153
|
+
| `name` | `String` | `Yes` | Name of the offline pack. |
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
const offlinePack = await MapLibreGL.offlineManager.getPack();
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
#### mergeOfflineRegions(path)
|
|
163
|
+
|
|
164
|
+
Sideloads offline db
|
|
165
|
+
|
|
166
|
+
##### arguments
|
|
167
|
+
| Name | Type | Required | Description |
|
|
168
|
+
| ---- | :--: | :------: | :----------: |
|
|
169
|
+
| `path` | `String` | `Yes` | Path to offline tile db on file system. |
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
await MapLibreGL.offlineManager.mergeOfflineRegions(path);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
#### setTileCountLimit(limit)
|
|
179
|
+
|
|
180
|
+
Sets the maximum number of tiles that may be downloaded and stored on the current device.<br/>Consult the Terms of Service for your map tile host before changing this value.
|
|
181
|
+
|
|
182
|
+
##### arguments
|
|
183
|
+
| Name | Type | Required | Description |
|
|
184
|
+
| ---- | :--: | :------: | :----------: |
|
|
185
|
+
| `limit` | `Number` | `Yes` | Map tile limit count. |
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
MapLibreGL.offlineManager.setTileCountLimit(1000);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
#### setProgressEventThrottle(throttleValue)
|
|
195
|
+
|
|
196
|
+
Sets the period at which download status events will be sent over the React Native bridge.<br/>The default is 500ms.
|
|
197
|
+
|
|
198
|
+
##### arguments
|
|
199
|
+
| Name | Type | Required | Description |
|
|
200
|
+
| ---- | :--: | :------: | :----------: |
|
|
201
|
+
| `throttleValue` | `Number` | `Yes` | event throttle value in ms. |
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
MapLibreGL.offlineManager.setProgressEventThrottle(500);
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
#### subscribe(packName, progressListener, errorListener)
|
|
211
|
+
|
|
212
|
+
Subscribe to download status/error events for the requested offline pack.<br/>Note that createPack calls this internally if listeners are provided.
|
|
213
|
+
|
|
214
|
+
##### arguments
|
|
215
|
+
| Name | Type | Required | Description |
|
|
216
|
+
| ---- | :--: | :------: | :----------: |
|
|
217
|
+
| `packName` | `String` | `Yes` | Name of the offline pack. |
|
|
218
|
+
| `progressListener` | `Callback` | `Yes` | Callback that listens for status events while downloading the offline resource. |
|
|
219
|
+
| `errorListener` | `Callback` | `Yes` | Callback that listens for status events while downloading the offline resource. |
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
const progressListener = (offlinePack, status) => console.log(offlinePack, status)
|
|
225
|
+
const errorListener = (offlinePack, err) => console.log(offlinePack, err)
|
|
226
|
+
MapLibreGL.offlineManager.subscribe('packName', progressListener, errorListener)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
#### unsubscribe(packName)
|
|
231
|
+
|
|
232
|
+
Unsubscribes any listeners associated with the offline pack.<br/>It's a good idea to call this on componentWillUnmount.
|
|
233
|
+
|
|
234
|
+
##### arguments
|
|
235
|
+
| Name | Type | Required | Description |
|
|
236
|
+
| ---- | :--: | :------: | :----------: |
|
|
237
|
+
| `packName` | `String` | `Yes` | Name of the offline pack. |
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
MapLibreGL.offlineManager.unsubscribe('packName')
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
package/javascript/Maplibre.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const _containerStyle: ViewStyle[] = [
|
|
97
|
+
{
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
zIndex: 999,
|
|
100
|
+
backgroundColor: 'transparent',
|
|
101
|
+
...containerStyle,
|
|
102
|
+
} as ViewStyle,
|
|
103
|
+
];
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
}
|
|
105
|
+
const _hasChildren = React.Children.count(children) > 0;
|
|
101
106
|
|
|
102
|
-
|
|
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,
|
|
109
|
-
<View style={[styles.content,
|
|
110
|
-
<Text style={[styles.title,
|
|
111
|
-
{
|
|
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,
|
|
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 {...
|
|
122
|
-
{
|
|
122
|
+
<Animated.View testID="container" {...props} style={style}>
|
|
123
|
+
{children}
|
|
123
124
|
</Animated.View>
|
|
124
125
|
);
|
|
125
|
-
}
|
|
126
|
+
};
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|