@rnmapbox/maps 10.0.3 → 10.0.4-rc.0
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/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +18 -4
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +24 -42
- package/ios/RCTMGL-v10/RCTMGLMapViewManager.m +5 -0
- package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +17 -0
- package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +5 -5
- package/lib/commonjs/components/MapView.js +16 -0
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/commonjs/modules/offline/offlineManager.js +48 -34
- package/lib/commonjs/modules/offline/offlineManager.js.map +1 -1
- package/lib/commonjs/utils/index.js +4 -1
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/MapView.js +16 -0
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/modules/offline/offlineManager.js +48 -34
- package/lib/module/modules/offline/offlineManager.js.map +1 -1
- package/lib/module/utils/index.js +4 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/components/MapView.d.ts +9 -0
- package/lib/typescript/components/MapView.d.ts.map +1 -1
- package/lib/typescript/modules/offline/offlineManager.d.ts +19 -15
- package/lib/typescript/modules/offline/offlineManager.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/MapView.tsx +18 -0
- package/src/modules/offline/offlineManager.ts +49 -34
- package/src/utils/index.ts +2 -1
|
@@ -46,7 +46,7 @@ declare class OfflineManager {
|
|
|
46
46
|
* const progressListener = (offlineRegion, status) => console.log(offlineRegion, status);
|
|
47
47
|
* const errorListener = (offlineRegion, err) => console.log(offlineRegion, err);
|
|
48
48
|
*
|
|
49
|
-
* await
|
|
49
|
+
* await Mapbox.offlineManager.createPack({
|
|
50
50
|
* name: 'offlinePack',
|
|
51
51
|
* styleURL: 'mapbox://...',
|
|
52
52
|
* minZoom: 14,
|
|
@@ -66,7 +66,7 @@ declare class OfflineManager {
|
|
|
66
66
|
* 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.
|
|
67
67
|
*
|
|
68
68
|
* @example
|
|
69
|
-
* await
|
|
69
|
+
* await Mapbox.offlineManager.invalidatePack('packName')
|
|
70
70
|
*
|
|
71
71
|
* @param {String} name Name of the offline pack.
|
|
72
72
|
* @return {void}
|
|
@@ -76,7 +76,7 @@ declare class OfflineManager {
|
|
|
76
76
|
* Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
|
|
77
77
|
*
|
|
78
78
|
* @example
|
|
79
|
-
* await
|
|
79
|
+
* await Mapbox.offlineManager.deletePack('packName')
|
|
80
80
|
*
|
|
81
81
|
* @param {String} name Name of the offline pack.
|
|
82
82
|
* @return {void}
|
|
@@ -88,8 +88,10 @@ declare class OfflineManager {
|
|
|
88
88
|
* This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.
|
|
89
89
|
* 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.
|
|
90
90
|
*
|
|
91
|
+
* @deprecated Not implemented in v10
|
|
92
|
+
*
|
|
91
93
|
* @example
|
|
92
|
-
* await
|
|
94
|
+
* await Mapbox.offlineManager.invalidateAmbientCache();
|
|
93
95
|
*
|
|
94
96
|
* @return {void}
|
|
95
97
|
*/
|
|
@@ -98,8 +100,10 @@ declare class OfflineManager {
|
|
|
98
100
|
* Erases resources from the ambient cache.
|
|
99
101
|
* This method clears the cache and decreases the amount of space that map resources take up on the device.
|
|
100
102
|
*
|
|
103
|
+
* @deprecated Not implemented in v10
|
|
104
|
+
*
|
|
101
105
|
* @example
|
|
102
|
-
* await
|
|
106
|
+
* await Mapbox.offlineManager.clearAmbientCache();
|
|
103
107
|
*
|
|
104
108
|
* @return {void}
|
|
105
109
|
*/
|
|
@@ -108,7 +112,7 @@ declare class OfflineManager {
|
|
|
108
112
|
* Migrates the offline cache from pre-v10 SDKs to the new v10 cache location
|
|
109
113
|
*
|
|
110
114
|
* @example
|
|
111
|
-
* await
|
|
115
|
+
* await Mapbox.offlineManager.migrateOfflineCache()
|
|
112
116
|
*
|
|
113
117
|
* @return {void}
|
|
114
118
|
*/
|
|
@@ -118,7 +122,7 @@ declare class OfflineManager {
|
|
|
118
122
|
* This method may be computationally expensive because it will erase resources from the ambient cache if its size is decreased.
|
|
119
123
|
*
|
|
120
124
|
* @example
|
|
121
|
-
* await
|
|
125
|
+
* await Mapbox.offlineManager.setMaximumAmbientCacheSize(5000000);
|
|
122
126
|
*
|
|
123
127
|
* @param {Number} size Size of ambient cache.
|
|
124
128
|
* @return {void}
|
|
@@ -128,7 +132,7 @@ declare class OfflineManager {
|
|
|
128
132
|
* Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
|
|
129
133
|
*
|
|
130
134
|
* @example
|
|
131
|
-
* await
|
|
135
|
+
* await Mapbox.offlineManager.resetDatabase();
|
|
132
136
|
*
|
|
133
137
|
* @return {void}
|
|
134
138
|
*/
|
|
@@ -137,7 +141,7 @@ declare class OfflineManager {
|
|
|
137
141
|
* Retrieves all the current offline packs that are stored in the database.
|
|
138
142
|
*
|
|
139
143
|
* @example
|
|
140
|
-
* const offlinePacks = await
|
|
144
|
+
* const offlinePacks = await Mapbox.offlineManager.getPacks();
|
|
141
145
|
*
|
|
142
146
|
* @return {Array<OfflinePack>}
|
|
143
147
|
*/
|
|
@@ -146,7 +150,7 @@ declare class OfflineManager {
|
|
|
146
150
|
* Retrieves an offline pack that is stored in the database by name.
|
|
147
151
|
*
|
|
148
152
|
* @example
|
|
149
|
-
* const offlinePack = await
|
|
153
|
+
* const offlinePack = await Mapbox.offlineManager.getPack();
|
|
150
154
|
*
|
|
151
155
|
* @param {String} name Name of the offline pack.
|
|
152
156
|
* @return {OfflinePack}
|
|
@@ -156,7 +160,7 @@ declare class OfflineManager {
|
|
|
156
160
|
* Sideloads offline db
|
|
157
161
|
*
|
|
158
162
|
* @example
|
|
159
|
-
* await
|
|
163
|
+
* await Mapbox.offlineManager.mergeOfflineRegions(path);
|
|
160
164
|
*
|
|
161
165
|
* @param {String} path Path to offline tile db on file system.
|
|
162
166
|
* @return {void}
|
|
@@ -167,7 +171,7 @@ declare class OfflineManager {
|
|
|
167
171
|
* The Mapbox Terms of Service prohibit changing or bypassing this limit without permission from Mapbox.
|
|
168
172
|
*
|
|
169
173
|
* @example
|
|
170
|
-
*
|
|
174
|
+
* Mapbox.offlineManager.setTileCountLimit(1000);
|
|
171
175
|
*
|
|
172
176
|
* @param {Number} limit Map tile limit count.
|
|
173
177
|
* @return {void}
|
|
@@ -178,7 +182,7 @@ declare class OfflineManager {
|
|
|
178
182
|
* The default is 300ms.
|
|
179
183
|
*
|
|
180
184
|
* @example
|
|
181
|
-
*
|
|
185
|
+
* Mapbox.offlineManager.setProgressEventThrottle(500);
|
|
182
186
|
*
|
|
183
187
|
* @param {Number} throttleValue event throttle value in ms.
|
|
184
188
|
* @return {void}
|
|
@@ -191,7 +195,7 @@ declare class OfflineManager {
|
|
|
191
195
|
* @example
|
|
192
196
|
* const progressListener = (offlinePack, status) => console.log(offlinePack, status)
|
|
193
197
|
* const errorListener = (offlinePack, err) => console.log(offlinePack, err)
|
|
194
|
-
*
|
|
198
|
+
* Mapbox.offlineManager.subscribe('packName', progressListener, errorListener)
|
|
195
199
|
*
|
|
196
200
|
* @param {String} packName Name of the offline pack.
|
|
197
201
|
* @param {Callback} progressListener Callback that listens for status events while downloading the offline resource.
|
|
@@ -204,7 +208,7 @@ declare class OfflineManager {
|
|
|
204
208
|
* It's a good idea to call this on componentWillUnmount.
|
|
205
209
|
*
|
|
206
210
|
* @example
|
|
207
|
-
*
|
|
211
|
+
* Mapbox.offlineManager.unsubscribe('packName')
|
|
208
212
|
*
|
|
209
213
|
* @param {String} packName Name of the offline pack.
|
|
210
214
|
* @return {void}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offlineManager.d.ts","sourceRoot":"","sources":["../../../../src/modules/offline/offlineManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,OAAO,IAAI,wBAAwB,EACnC,KAAK,4BAA4B,GAClC,MAAM,4BAA4B,CAAC;AACpC,OAAiC,EAC/B,KAAK,4BAA4B,EAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"offlineManager.d.ts","sourceRoot":"","sources":["../../../../src/modules/offline/offlineManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,OAAO,IAAI,wBAAwB,EACnC,KAAK,4BAA4B,GAClC,MAAM,4BAA4B,CAAC;AACpC,OAAiC,EAC/B,KAAK,4BAA4B,EAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AAKxC,eAAO,MAAM,yBAAyB,oBAErC,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,aAAK,UAAU,GAAG;IAChB,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,aA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,GAC9B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -747,6 +747,24 @@ class MapView extends NativeBridgeComponent(
|
|
|
747
747
|
return res.center;
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
+
/**
|
|
751
|
+
*
|
|
752
|
+
* Clears temporary map data from the data path defined in the given resource
|
|
753
|
+
* options. Useful to reduce the disk usage or in case the disk cache contains
|
|
754
|
+
* invalid data.
|
|
755
|
+
*
|
|
756
|
+
* v10 only
|
|
757
|
+
*/
|
|
758
|
+
async clearData(): Promise<void> {
|
|
759
|
+
if (!MGLModule.MapboxV10) {
|
|
760
|
+
console.warn(
|
|
761
|
+
'RNMapbox: clearData is only implemented in v10 implementation or later',
|
|
762
|
+
);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
await this._runNative<void>('clearData');
|
|
766
|
+
}
|
|
767
|
+
|
|
750
768
|
/**
|
|
751
769
|
* Queries the currently loaded data for elevation at a geographical location.
|
|
752
770
|
* The elevation is returned in meters relative to mean sea-level.
|
|
@@ -15,10 +15,11 @@ import OfflineCreatePackOptions, {
|
|
|
15
15
|
} from './OfflineCreatePackOptions';
|
|
16
16
|
import OfflinePack from './OfflinePack';
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const { MGLModule } = NativeModules;
|
|
19
|
+
|
|
20
|
+
const MapboxOfflineManager = NativeModules.MGLOfflineModule;
|
|
20
21
|
export const OfflineModuleEventEmitter = new NativeEventEmitter(
|
|
21
|
-
|
|
22
|
+
MapboxOfflineManager,
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
export type OfflineProgressStatus = {
|
|
@@ -86,7 +87,7 @@ class OfflineManager {
|
|
|
86
87
|
* const progressListener = (offlineRegion, status) => console.log(offlineRegion, status);
|
|
87
88
|
* const errorListener = (offlineRegion, err) => console.log(offlineRegion, err);
|
|
88
89
|
*
|
|
89
|
-
* await
|
|
90
|
+
* await Mapbox.offlineManager.createPack({
|
|
90
91
|
* name: 'offlinePack',
|
|
91
92
|
* styleURL: 'mapbox://...',
|
|
92
93
|
* minZoom: 14,
|
|
@@ -115,7 +116,7 @@ class OfflineManager {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
this.subscribe(packOptions.name, progressListener, errorListener);
|
|
118
|
-
const nativeOfflinePack = await
|
|
119
|
+
const nativeOfflinePack = await MapboxOfflineManager.createPack(
|
|
119
120
|
packOptions,
|
|
120
121
|
);
|
|
121
122
|
this._offlinePacks[packOptions.name] = new OfflinePack(nativeOfflinePack);
|
|
@@ -127,7 +128,7 @@ class OfflineManager {
|
|
|
127
128
|
* 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.
|
|
128
129
|
*
|
|
129
130
|
* @example
|
|
130
|
-
* await
|
|
131
|
+
* await Mapbox.offlineManager.invalidatePack('packName')
|
|
131
132
|
*
|
|
132
133
|
* @param {String} name Name of the offline pack.
|
|
133
134
|
* @return {void}
|
|
@@ -141,7 +142,7 @@ class OfflineManager {
|
|
|
141
142
|
|
|
142
143
|
const offlinePack = this._offlinePacks[name];
|
|
143
144
|
if (offlinePack) {
|
|
144
|
-
await
|
|
145
|
+
await MapboxOfflineManager.invalidatePack(name);
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
|
|
@@ -149,7 +150,7 @@ class OfflineManager {
|
|
|
149
150
|
* Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
|
|
150
151
|
*
|
|
151
152
|
* @example
|
|
152
|
-
* await
|
|
153
|
+
* await Mapbox.offlineManager.deletePack('packName')
|
|
153
154
|
*
|
|
154
155
|
* @param {String} name Name of the offline pack.
|
|
155
156
|
* @return {void}
|
|
@@ -163,7 +164,7 @@ class OfflineManager {
|
|
|
163
164
|
|
|
164
165
|
const offlinePack = this._offlinePacks[name];
|
|
165
166
|
if (offlinePack) {
|
|
166
|
-
await
|
|
167
|
+
await MapboxOfflineManager.deletePack(name);
|
|
167
168
|
delete this._offlinePacks[name];
|
|
168
169
|
}
|
|
169
170
|
}
|
|
@@ -174,41 +175,55 @@ class OfflineManager {
|
|
|
174
175
|
* This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.
|
|
175
176
|
* 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.
|
|
176
177
|
*
|
|
178
|
+
* @deprecated Not implemented in v10
|
|
179
|
+
*
|
|
177
180
|
* @example
|
|
178
|
-
* await
|
|
181
|
+
* await Mapbox.offlineManager.invalidateAmbientCache();
|
|
179
182
|
*
|
|
180
183
|
* @return {void}
|
|
181
184
|
*/
|
|
182
185
|
async invalidateAmbientCache(): Promise<void> {
|
|
186
|
+
if (MGLModule.MapboxV10) {
|
|
187
|
+
console.warn(
|
|
188
|
+
'RNMapbox: invalidateAmbientCache is not implemented on v10',
|
|
189
|
+
);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
183
192
|
await this._initialize();
|
|
184
|
-
await
|
|
193
|
+
await MapboxOfflineManager.invalidateAmbientCache();
|
|
185
194
|
}
|
|
186
195
|
|
|
187
196
|
/**
|
|
188
197
|
* Erases resources from the ambient cache.
|
|
189
198
|
* This method clears the cache and decreases the amount of space that map resources take up on the device.
|
|
190
199
|
*
|
|
200
|
+
* @deprecated Not implemented in v10
|
|
201
|
+
*
|
|
191
202
|
* @example
|
|
192
|
-
* await
|
|
203
|
+
* await Mapbox.offlineManager.clearAmbientCache();
|
|
193
204
|
*
|
|
194
205
|
* @return {void}
|
|
195
206
|
*/
|
|
196
207
|
async clearAmbientCache(): Promise<void> {
|
|
208
|
+
if (MGLModule.MapboxV10) {
|
|
209
|
+
console.warn('RNMapbox: clearAmbientCache is not implemented on v10');
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
197
212
|
await this._initialize();
|
|
198
|
-
await
|
|
213
|
+
await MapboxOfflineManager.clearAmbientCache();
|
|
199
214
|
}
|
|
200
215
|
|
|
201
216
|
/**
|
|
202
217
|
* Migrates the offline cache from pre-v10 SDKs to the new v10 cache location
|
|
203
218
|
*
|
|
204
219
|
* @example
|
|
205
|
-
* await
|
|
220
|
+
* await Mapbox.offlineManager.migrateOfflineCache()
|
|
206
221
|
*
|
|
207
222
|
* @return {void}
|
|
208
223
|
*/
|
|
209
224
|
async migrateOfflineCache(): Promise<void> {
|
|
210
225
|
await this._initialize();
|
|
211
|
-
await
|
|
226
|
+
await MapboxOfflineManager.migrateOfflineCache();
|
|
212
227
|
}
|
|
213
228
|
|
|
214
229
|
/**
|
|
@@ -216,34 +231,34 @@ class OfflineManager {
|
|
|
216
231
|
* This method may be computationally expensive because it will erase resources from the ambient cache if its size is decreased.
|
|
217
232
|
*
|
|
218
233
|
* @example
|
|
219
|
-
* await
|
|
234
|
+
* await Mapbox.offlineManager.setMaximumAmbientCacheSize(5000000);
|
|
220
235
|
*
|
|
221
236
|
* @param {Number} size Size of ambient cache.
|
|
222
237
|
* @return {void}
|
|
223
238
|
*/
|
|
224
239
|
async setMaximumAmbientCacheSize(size: number): Promise<void> {
|
|
225
240
|
await this._initialize();
|
|
226
|
-
await
|
|
241
|
+
await MapboxOfflineManager.setMaximumAmbientCacheSize(size);
|
|
227
242
|
}
|
|
228
243
|
|
|
229
244
|
/**
|
|
230
245
|
* Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
|
|
231
246
|
*
|
|
232
247
|
* @example
|
|
233
|
-
* await
|
|
248
|
+
* await Mapbox.offlineManager.resetDatabase();
|
|
234
249
|
*
|
|
235
250
|
* @return {void}
|
|
236
251
|
*/
|
|
237
252
|
async resetDatabase(): Promise<void> {
|
|
238
253
|
await this._initialize();
|
|
239
|
-
await
|
|
254
|
+
await MapboxOfflineManager.resetDatabase();
|
|
240
255
|
}
|
|
241
256
|
|
|
242
257
|
/**
|
|
243
258
|
* Retrieves all the current offline packs that are stored in the database.
|
|
244
259
|
*
|
|
245
260
|
* @example
|
|
246
|
-
* const offlinePacks = await
|
|
261
|
+
* const offlinePacks = await Mapbox.offlineManager.getPacks();
|
|
247
262
|
*
|
|
248
263
|
* @return {Array<OfflinePack>}
|
|
249
264
|
*/
|
|
@@ -258,7 +273,7 @@ class OfflineManager {
|
|
|
258
273
|
* Retrieves an offline pack that is stored in the database by name.
|
|
259
274
|
*
|
|
260
275
|
* @example
|
|
261
|
-
* const offlinePack = await
|
|
276
|
+
* const offlinePack = await Mapbox.offlineManager.getPack();
|
|
262
277
|
*
|
|
263
278
|
* @param {String} name Name of the offline pack.
|
|
264
279
|
* @return {OfflinePack}
|
|
@@ -272,14 +287,14 @@ class OfflineManager {
|
|
|
272
287
|
* Sideloads offline db
|
|
273
288
|
*
|
|
274
289
|
* @example
|
|
275
|
-
* await
|
|
290
|
+
* await Mapbox.offlineManager.mergeOfflineRegions(path);
|
|
276
291
|
*
|
|
277
292
|
* @param {String} path Path to offline tile db on file system.
|
|
278
293
|
* @return {void}
|
|
279
294
|
*/
|
|
280
295
|
async mergeOfflineRegions(path: string): Promise<void> {
|
|
281
296
|
await this._initialize();
|
|
282
|
-
return
|
|
297
|
+
return MapboxOfflineManager.mergeOfflineRegions(path);
|
|
283
298
|
}
|
|
284
299
|
|
|
285
300
|
/**
|
|
@@ -287,13 +302,13 @@ class OfflineManager {
|
|
|
287
302
|
* The Mapbox Terms of Service prohibit changing or bypassing this limit without permission from Mapbox.
|
|
288
303
|
*
|
|
289
304
|
* @example
|
|
290
|
-
*
|
|
305
|
+
* Mapbox.offlineManager.setTileCountLimit(1000);
|
|
291
306
|
*
|
|
292
307
|
* @param {Number} limit Map tile limit count.
|
|
293
308
|
* @return {void}
|
|
294
309
|
*/
|
|
295
310
|
setTileCountLimit(limit: number): void {
|
|
296
|
-
|
|
311
|
+
MapboxOfflineManager.setTileCountLimit(limit);
|
|
297
312
|
}
|
|
298
313
|
|
|
299
314
|
/**
|
|
@@ -301,13 +316,13 @@ class OfflineManager {
|
|
|
301
316
|
* The default is 300ms.
|
|
302
317
|
*
|
|
303
318
|
* @example
|
|
304
|
-
*
|
|
319
|
+
* Mapbox.offlineManager.setProgressEventThrottle(500);
|
|
305
320
|
*
|
|
306
321
|
* @param {Number} throttleValue event throttle value in ms.
|
|
307
322
|
* @return {void}
|
|
308
323
|
*/
|
|
309
324
|
setProgressEventThrottle(throttleValue: number): void {
|
|
310
|
-
|
|
325
|
+
MapboxOfflineManager.setProgressEventThrottle(throttleValue);
|
|
311
326
|
}
|
|
312
327
|
|
|
313
328
|
/**
|
|
@@ -317,7 +332,7 @@ class OfflineManager {
|
|
|
317
332
|
* @example
|
|
318
333
|
* const progressListener = (offlinePack, status) => console.log(offlinePack, status)
|
|
319
334
|
* const errorListener = (offlinePack, err) => console.log(offlinePack, err)
|
|
320
|
-
*
|
|
335
|
+
* Mapbox.offlineManager.subscribe('packName', progressListener, errorListener)
|
|
321
336
|
*
|
|
322
337
|
* @param {String} packName Name of the offline pack.
|
|
323
338
|
* @param {Callback} progressListener Callback that listens for status events while downloading the offline resource.
|
|
@@ -333,7 +348,7 @@ class OfflineManager {
|
|
|
333
348
|
if (isFunction(progressListener)) {
|
|
334
349
|
if (totalProgressListeners === 0) {
|
|
335
350
|
this.subscriptionProgress = OfflineModuleEventEmitter.addListener(
|
|
336
|
-
|
|
351
|
+
MGLModule.OfflineCallbackName.Progress,
|
|
337
352
|
this._onProgress,
|
|
338
353
|
);
|
|
339
354
|
}
|
|
@@ -344,7 +359,7 @@ class OfflineManager {
|
|
|
344
359
|
if (isFunction(errorListener)) {
|
|
345
360
|
if (totalErrorListeners === 0) {
|
|
346
361
|
this.subscriptionError = OfflineModuleEventEmitter.addListener(
|
|
347
|
-
|
|
362
|
+
MGLModule.OfflineCallbackName.Error,
|
|
348
363
|
this._onError,
|
|
349
364
|
);
|
|
350
365
|
}
|
|
@@ -356,7 +371,7 @@ class OfflineManager {
|
|
|
356
371
|
if (isAndroid() && this._offlinePacks[packName]) {
|
|
357
372
|
try {
|
|
358
373
|
// manually set a listener, since listeners are only set on create flow
|
|
359
|
-
await
|
|
374
|
+
await MapboxOfflineManager.setPackObserver(packName);
|
|
360
375
|
} catch (e) {
|
|
361
376
|
console.log('Unable to set pack observer', e);
|
|
362
377
|
}
|
|
@@ -368,7 +383,7 @@ class OfflineManager {
|
|
|
368
383
|
* It's a good idea to call this on componentWillUnmount.
|
|
369
384
|
*
|
|
370
385
|
* @example
|
|
371
|
-
*
|
|
386
|
+
* Mapbox.offlineManager.unsubscribe('packName')
|
|
372
387
|
*
|
|
373
388
|
* @param {String} packName Name of the offline pack.
|
|
374
389
|
* @return {void}
|
|
@@ -397,7 +412,7 @@ class OfflineManager {
|
|
|
397
412
|
return true;
|
|
398
413
|
}
|
|
399
414
|
|
|
400
|
-
const nativeOfflinePacks = await
|
|
415
|
+
const nativeOfflinePacks = await MapboxOfflineManager.getPacks();
|
|
401
416
|
|
|
402
417
|
for (const nativeOfflinePack of nativeOfflinePacks) {
|
|
403
418
|
const offlinePack = new OfflinePack(nativeOfflinePack);
|
|
@@ -419,7 +434,7 @@ class OfflineManager {
|
|
|
419
434
|
this._progressListeners[name](pack, e.payload);
|
|
420
435
|
|
|
421
436
|
// cleanup listeners now that they are no longer needed
|
|
422
|
-
if (state ===
|
|
437
|
+
if (state === MGLModule.OfflinePackDownloadState.Complete) {
|
|
423
438
|
this.unsubscribe(name);
|
|
424
439
|
}
|
|
425
440
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -85,9 +85,10 @@ export function runNativeCommand<ReturnType = NativeArg>(
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
if (isAndroid()) {
|
|
88
|
+
const { Commands } = managerInstance;
|
|
88
89
|
return NativeModules.UIManager.dispatchViewManagerCommand(
|
|
89
90
|
handle,
|
|
90
|
-
|
|
91
|
+
Commands._useCommandName ? name : Commands[name],
|
|
91
92
|
args,
|
|
92
93
|
);
|
|
93
94
|
}
|