@rnmapbox/maps 10.0.0-beta.65 → 10.0.0-beta.67
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/camera/RCTMGLCamera.kt +1 -1
- package/index.d.ts +36 -166
- package/ios/RCTMGL-v10/RCTMGLLogging.swift +13 -0
- package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +86 -55
- package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +138 -55
- package/javascript/components/BackgroundLayer.tsx +91 -0
- package/javascript/components/CircleLayer.tsx +97 -0
- package/javascript/components/FillExtrusionLayer.tsx +95 -0
- package/javascript/components/FillLayer.tsx +91 -0
- package/javascript/components/HeatmapLayer.tsx +96 -0
- package/javascript/components/NativeUserLocation.tsx +33 -0
- package/javascript/components/RasterLayer.tsx +88 -0
- package/javascript/components/SkyLayer.tsx +70 -0
- package/javascript/modules/location/locationManager.js +3 -1
- package/lib/commonjs/components/BackgroundLayer.js +6 -55
- package/lib/commonjs/components/BackgroundLayer.js.map +1 -1
- package/lib/commonjs/components/CircleLayer.js +8 -58
- package/lib/commonjs/components/CircleLayer.js.map +1 -1
- package/lib/commonjs/components/FillExtrusionLayer.js +3 -55
- package/lib/commonjs/components/FillExtrusionLayer.js.map +1 -1
- package/lib/commonjs/components/FillLayer.js +2 -55
- package/lib/commonjs/components/FillLayer.js.map +1 -1
- package/lib/commonjs/components/HeatmapLayer.js +3 -56
- package/lib/commonjs/components/HeatmapLayer.js.map +1 -1
- package/lib/commonjs/components/NativeUserLocation.js +6 -31
- package/lib/commonjs/components/NativeUserLocation.js.map +1 -1
- package/lib/commonjs/components/RasterLayer.js +1 -53
- package/lib/commonjs/components/RasterLayer.js.map +1 -1
- package/lib/commonjs/components/SkyLayer.js +2 -43
- package/lib/commonjs/components/SkyLayer.js.map +1 -1
- package/lib/commonjs/modules/location/locationManager.js +3 -1
- package/lib/commonjs/modules/location/locationManager.js.map +1 -1
- package/lib/module/components/BackgroundLayer.js +6 -55
- package/lib/module/components/BackgroundLayer.js.map +1 -1
- package/lib/module/components/CircleLayer.js +7 -57
- package/lib/module/components/CircleLayer.js.map +1 -1
- package/lib/module/components/FillExtrusionLayer.js +2 -54
- package/lib/module/components/FillExtrusionLayer.js.map +1 -1
- package/lib/module/components/FillLayer.js +1 -54
- package/lib/module/components/FillLayer.js.map +1 -1
- package/lib/module/components/HeatmapLayer.js +2 -55
- package/lib/module/components/HeatmapLayer.js.map +1 -1
- package/lib/module/components/NativeUserLocation.js +4 -30
- package/lib/module/components/NativeUserLocation.js.map +1 -1
- package/lib/module/components/RasterLayer.js +1 -53
- package/lib/module/components/RasterLayer.js.map +1 -1
- package/lib/module/components/SkyLayer.js +1 -42
- package/lib/module/components/SkyLayer.js.map +1 -1
- package/lib/module/modules/location/locationManager.js +3 -1
- package/lib/module/modules/location/locationManager.js.map +1 -1
- package/lib/typescript/components/BackgroundLayer.d.ts +62 -0
- package/lib/typescript/components/BackgroundLayer.d.ts.map +1 -0
- package/lib/typescript/components/CircleLayer.d.ts +66 -0
- package/lib/typescript/components/CircleLayer.d.ts.map +1 -0
- package/lib/typescript/components/FillExtrusionLayer.d.ts +65 -0
- package/lib/typescript/components/FillExtrusionLayer.d.ts.map +1 -0
- package/{javascript/components/FillLayer.js → lib/typescript/components/FillLayer.d.ts} +28 -57
- package/lib/typescript/components/FillLayer.d.ts.map +1 -0
- package/lib/typescript/components/HeatmapLayer.d.ts +66 -0
- package/lib/typescript/components/HeatmapLayer.d.ts.map +1 -0
- package/lib/typescript/components/NativeUserLocation.d.ts +22 -0
- package/lib/typescript/components/NativeUserLocation.d.ts.map +1 -0
- package/lib/typescript/components/RasterLayer.d.ts +62 -0
- package/lib/typescript/components/RasterLayer.d.ts.map +1 -0
- package/lib/typescript/components/SkyLayer.d.ts +52 -0
- package/lib/typescript/components/SkyLayer.d.ts.map +1 -0
- package/package.json +1 -1
- package/javascript/components/BackgroundLayer.js +0 -97
- package/javascript/components/CircleLayer.js +0 -101
- package/javascript/components/FillExtrusionLayer.js +0 -98
- package/javascript/components/HeatmapLayer.js +0 -99
- package/javascript/components/NativeUserLocation.js +0 -41
- package/javascript/components/RasterLayer.js +0 -95
- package/javascript/components/SkyLayer.js +0 -80
|
@@ -11,10 +11,14 @@ extension Date {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
|
|
15
|
+
|
|
14
16
|
@objc(RCTMGLOfflineModule)
|
|
15
17
|
class RCTMGLOfflineModule: RCTEventEmitter {
|
|
16
18
|
var hasListeners = false
|
|
17
19
|
|
|
20
|
+
static let RNMapboxInfoMetadataKey = "_rnmapbox"
|
|
21
|
+
|
|
18
22
|
enum Callbacks : String {
|
|
19
23
|
case error = "MapboOfflineRegionError"
|
|
20
24
|
case progress = "MapboxOfflineRegionProgress"
|
|
@@ -37,11 +41,65 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
37
41
|
}()
|
|
38
42
|
|
|
39
43
|
struct TileRegionPack {
|
|
44
|
+
init(name: String, state: State = .unknown, progress: TileRegionLoadProgress? = nil, metadata: [String:Any]) {
|
|
45
|
+
self.name = name
|
|
46
|
+
self.progress = progress
|
|
47
|
+
self.metadata = metadata
|
|
48
|
+
self.state = state
|
|
49
|
+
|
|
50
|
+
if let rnMetadata = metadata[RNMapboxInfoMetadataKey] as? [String:Any] {
|
|
51
|
+
if let styleURI = rnMetadata["styleURI"] as? String {
|
|
52
|
+
self.styleURI = StyleURI(rawValue: styleURI)
|
|
53
|
+
}
|
|
54
|
+
if let bounds = rnMetadata["bounds"] as? JSONObject {
|
|
55
|
+
self.bounds = logged("RCTMGLOfflineModule.TileRegionPack: cannot decode bounds") {
|
|
56
|
+
let jsonData = try JSONSerialization.data(withJSONObject: bounds)
|
|
57
|
+
return try JSONDecoder().decode(Geometry.self, from: jsonData)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if let zoomRange = rnMetadata["zoomRange"] as? JSONObject {
|
|
61
|
+
self.zoomRange = logged("RCTMGLOfflineModule.TileRegionPack: cannot decode zoomRange") {
|
|
62
|
+
let jsonData = try JSONSerialization.data(withJSONObject: zoomRange)
|
|
63
|
+
return try JSONDecoder().decode(ClosedRange<UInt8>.self, from: jsonData)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
init(name: String,
|
|
70
|
+
state: State = .unknown,
|
|
71
|
+
styleURI: StyleURI,
|
|
72
|
+
bounds: Geometry,
|
|
73
|
+
zoomRange: ClosedRange<UInt8>,
|
|
74
|
+
metadata: [String:Any]) {
|
|
75
|
+
self.name = name
|
|
76
|
+
self.progress = nil
|
|
77
|
+
self.cancelable = nil
|
|
78
|
+
self.state = state
|
|
79
|
+
|
|
80
|
+
self.styleURI = styleURI
|
|
81
|
+
self.bounds = bounds
|
|
82
|
+
self.zoomRange = zoomRange
|
|
83
|
+
|
|
84
|
+
var metadata = metadata
|
|
85
|
+
metadata[RNMapboxInfoMetadataKey] = [
|
|
86
|
+
"styleURI": styleURI.rawValue,
|
|
87
|
+
"bounds": logged("RCTMGLOfflineModule.TileRegionPack: cannot encode bounds") { try JSONSerialization.jsonObject(with: try! JSONEncoder().encode(bounds)) },
|
|
88
|
+
"zoomRange": logged("RCTMGLOfflineModule.TileRegionPack: cannot encode zoomRange") { try JSONSerialization.jsonObject(with: try! JSONEncoder().encode(zoomRange))}
|
|
89
|
+
]
|
|
90
|
+
self.metadata = metadata
|
|
91
|
+
}
|
|
92
|
+
|
|
40
93
|
var name: String
|
|
41
94
|
var cancelable: Cancelable? = nil
|
|
42
95
|
var progress : TileRegionLoadProgress? = nil
|
|
43
96
|
var state : State = .inactive
|
|
44
97
|
var metadata : [String:Any]? = nil
|
|
98
|
+
|
|
99
|
+
// Stored in metadata for resume functionality:
|
|
100
|
+
var bounds: Geometry? = nil
|
|
101
|
+
var zoomRange: ClosedRange<UInt8>? = nil
|
|
102
|
+
var styleURI: StyleURI? = nil
|
|
45
103
|
}
|
|
46
104
|
|
|
47
105
|
lazy var tileRegionPacks : [String: TileRegionPack] = [:]
|
|
@@ -116,7 +174,7 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
116
174
|
if let expires = region.expires {
|
|
117
175
|
result["expires"] = expires.toJSONString()
|
|
118
176
|
}
|
|
119
|
-
|
|
177
|
+
|
|
120
178
|
result["metadata"] = String(data:try! JSONSerialization.data(withJSONObject: metadata, options: [.prettyPrinted]), encoding: .utf8)
|
|
121
179
|
|
|
122
180
|
result["bounds"] = jsonBounds
|
|
@@ -182,9 +240,9 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
182
240
|
let ret = self.convertRegionToJSON(region: region, geometry: geometry, metadata: metadata)
|
|
183
241
|
var pack = self.tileRegionPacks[region.id] ?? TileRegionPack(
|
|
184
242
|
name: region.id,
|
|
185
|
-
progress: self.toProgress(region: region),
|
|
186
243
|
state: .unknown,
|
|
187
|
-
|
|
244
|
+
progress: self.toProgress(region: region),
|
|
245
|
+
metadata: logged("RCTMGLOfflineModule.getPacks metadata is null") { metadata } ?? [:]
|
|
188
246
|
)
|
|
189
247
|
|
|
190
248
|
if ((region.completedResourceCount == region.completedResourceSize)) {
|
|
@@ -327,9 +385,9 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
327
385
|
DispatchQueue.main.async {
|
|
328
386
|
do {
|
|
329
387
|
let metadataStr = options["metadata"] as! String
|
|
330
|
-
|
|
388
|
+
var metadata = try JSONSerialization.jsonObject(with: metadataStr.data(using: .utf8)!, options: []) as! [String:Any]
|
|
389
|
+
metadata["styleURI"] = options["styleURL"]
|
|
331
390
|
let id = metadata["name"] as! String
|
|
332
|
-
let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: metadata)
|
|
333
391
|
|
|
334
392
|
let boundsStr = options["bounds"] as! String
|
|
335
393
|
let boundsData = boundsStr.data(using: .utf8)
|
|
@@ -337,53 +395,16 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
337
395
|
|
|
338
396
|
var bounds = self.convertPointPairToBounds(RCTMGLFeatureUtils.fcToGeomtry(boundsFC))
|
|
339
397
|
|
|
340
|
-
let descriptorOptions = TilesetDescriptorOptions(
|
|
341
|
-
styleURI: StyleURI(rawValue: options["styleURL"] as! String)!,
|
|
342
|
-
zoomRange: (options["minZoom"] as! NSNumber).uint8Value...(options["maxZoom"] as! NSNumber).uint8Value,
|
|
343
|
-
stylePackOptions: stylePackLoadOptions
|
|
344
|
-
)
|
|
345
|
-
let tilesetDescriptor = self.offlineManager.createTilesetDescriptor(for: descriptorOptions)
|
|
346
|
-
|
|
347
|
-
let loadOptions = TileRegionLoadOptions(
|
|
348
|
-
geometry: bounds, // RCTMGLFeatureUtils.geometryToGeometry(bounds),
|
|
349
|
-
descriptors: [tilesetDescriptor],
|
|
350
|
-
metadata: metadata,
|
|
351
|
-
acceptExpired: true,
|
|
352
|
-
networkRestriction: .none,
|
|
353
|
-
averageBytesPerSecond: nil)
|
|
354
|
-
|
|
355
398
|
let actPack = RCTMGLOfflineModule.TileRegionPack(
|
|
356
399
|
name: id,
|
|
357
|
-
|
|
358
|
-
|
|
400
|
+
styleURI: StyleURI(rawValue: options["styleURL"] as! String)!,
|
|
401
|
+
bounds: bounds,
|
|
402
|
+
zoomRange: (options["minZoom"] as! NSNumber).uint8Value...(options["maxZoom"] as! NSNumber).uint8Value,
|
|
403
|
+
metadata: metadata
|
|
359
404
|
)
|
|
360
405
|
self.tileRegionPacks[id] = actPack
|
|
406
|
+
self.startLoading(pack: actPack)
|
|
361
407
|
|
|
362
|
-
var lastProgress : TileRegionLoadProgress? = nil
|
|
363
|
-
let task = self.tileStore.loadTileRegion(forId: id, loadOptions: loadOptions!, progress: {
|
|
364
|
-
progress in
|
|
365
|
-
lastProgress = progress
|
|
366
|
-
self.tileRegionPacks[id]!.progress = progress
|
|
367
|
-
self.tileRegionPacks[id]!.state = .active
|
|
368
|
-
self.offlinePackProgressDidChange(progress: progress, metadata: metadata, state: .active)
|
|
369
|
-
}) { result in
|
|
370
|
-
switch result {
|
|
371
|
-
case .success(let value):
|
|
372
|
-
DispatchQueue.main.async {
|
|
373
|
-
if let progess = lastProgress {
|
|
374
|
-
self.offlinePackProgressDidChange(progress: progess, metadata: metadata, state: .complete)
|
|
375
|
-
}
|
|
376
|
-
self.tileRegionPacks[id]!.state = .complete
|
|
377
|
-
}
|
|
378
|
-
case .failure(let error):
|
|
379
|
-
DispatchQueue.main.async {
|
|
380
|
-
self.tileRegionPacks[id]!.state = .inactive
|
|
381
|
-
self.offlinePackDidReceiveError(name: id, error: error)
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
self.tileRegionPacks[id]!.cancelable = task
|
|
387
408
|
resolver([
|
|
388
409
|
"bounds": boundsStr,
|
|
389
410
|
"metadata": String(data:try! JSONSerialization.data(withJSONObject: metadata, options: [.prettyPrinted]), encoding: .utf8)
|
|
@@ -394,10 +415,72 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
394
415
|
}
|
|
395
416
|
}
|
|
396
417
|
|
|
418
|
+
func startLoading(pack: TileRegionPack) {
|
|
419
|
+
let id = pack.name
|
|
420
|
+
guard let bounds = pack.bounds else {
|
|
421
|
+
RCTMGLLogError("RCTMGLOfflineModule.startLoading failed as there are no bounds in pack")
|
|
422
|
+
return
|
|
423
|
+
}
|
|
424
|
+
guard let zoomRange = pack.zoomRange else {
|
|
425
|
+
RCTMGLLogError("RCTMGLOfflineModule.startLoading failed as there is no zoom range in pack")
|
|
426
|
+
return
|
|
427
|
+
}
|
|
428
|
+
guard let styleURI = pack.styleURI else {
|
|
429
|
+
RCTMGLLogError("RCTMGLOfflineModule.startLoading failed as there is no styleURI in pack")
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
guard let metadata = pack.metadata else {
|
|
433
|
+
RCTMGLLogError("RCTMGLOfflineModule.startLoading failed as there is no metadata in pack")
|
|
434
|
+
return
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: pack.metadata)
|
|
438
|
+
|
|
439
|
+
let descriptorOptions = TilesetDescriptorOptions(
|
|
440
|
+
styleURI: styleURI,
|
|
441
|
+
zoomRange: zoomRange,
|
|
442
|
+
stylePackOptions: stylePackLoadOptions
|
|
443
|
+
)
|
|
444
|
+
let tilesetDescriptor = self.offlineManager.createTilesetDescriptor(for: descriptorOptions)
|
|
445
|
+
|
|
446
|
+
let loadOptions = TileRegionLoadOptions(
|
|
447
|
+
geometry: bounds, // RCTMGLFeatureUtils.geometryToGeometry(bounds),
|
|
448
|
+
descriptors: [tilesetDescriptor],
|
|
449
|
+
metadata: metadata,
|
|
450
|
+
acceptExpired: true,
|
|
451
|
+
networkRestriction: .none,
|
|
452
|
+
averageBytesPerSecond: nil)
|
|
453
|
+
|
|
454
|
+
var lastProgress : TileRegionLoadProgress? = nil
|
|
455
|
+
let task = self.tileStore.loadTileRegion(forId: id, loadOptions: loadOptions!, progress: {
|
|
456
|
+
progress in
|
|
457
|
+
lastProgress = progress
|
|
458
|
+
self.tileRegionPacks[id]!.progress = progress
|
|
459
|
+
self.tileRegionPacks[id]!.state = .active
|
|
460
|
+
self.offlinePackProgressDidChange(progress: progress, metadata: metadata, state: .active)
|
|
461
|
+
}) { result in
|
|
462
|
+
switch result {
|
|
463
|
+
case .success(let value):
|
|
464
|
+
DispatchQueue.main.async {
|
|
465
|
+
if let progess = lastProgress {
|
|
466
|
+
self.offlinePackProgressDidChange(progress: progess, metadata: metadata, state: .complete)
|
|
467
|
+
}
|
|
468
|
+
self.tileRegionPacks[id]!.state = .complete
|
|
469
|
+
}
|
|
470
|
+
case .failure(let error):
|
|
471
|
+
DispatchQueue.main.async {
|
|
472
|
+
self.tileRegionPacks[id]!.state = .inactive
|
|
473
|
+
self.offlinePackDidReceiveError(name: id, error: error)
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
self.tileRegionPacks[id]!.cancelable = task
|
|
478
|
+
}
|
|
479
|
+
|
|
397
480
|
func _getPack(fromName: String) -> TileRegionPack? {
|
|
398
481
|
return self.tileRegionPacks[fromName]
|
|
399
482
|
}
|
|
400
|
-
|
|
483
|
+
|
|
401
484
|
@objc
|
|
402
485
|
func getPackStatus(_ name: String,
|
|
403
486
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
@@ -413,12 +496,10 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
413
496
|
Logger.log(level:.error, message: "Unable to fetch metadata for \(name)")
|
|
414
497
|
rejecter("RCTMGLOfflineModule.getPackStatus", error.localizedDescription, error)
|
|
415
498
|
case .success(let metadata):
|
|
416
|
-
var pack = self.tileRegionPacks[name] ?? TileRegionPack(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
Logger.log(level:.error, message: "Unexpected metadata format for \(name) \(metadata)")
|
|
421
|
-
}
|
|
499
|
+
var pack = self.tileRegionPacks[name] ?? TileRegionPack(
|
|
500
|
+
name: name,
|
|
501
|
+
metadata: logged("RCTMGLOfflineModule.getPackStatus") { metadata as? [String:Any] } ?? [:]
|
|
502
|
+
)
|
|
422
503
|
self.tileRegionPacks[name] = pack
|
|
423
504
|
resolver(self._makeRegionStatusPayload(pack: pack))
|
|
424
505
|
}
|
|
@@ -429,7 +510,9 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
429
510
|
@objc
|
|
430
511
|
func resumePackDownload(_ name: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock)
|
|
431
512
|
{
|
|
432
|
-
|
|
513
|
+
if let pack = _getPack(fromName: name) {
|
|
514
|
+
self.startLoading(pack: pack)
|
|
515
|
+
}
|
|
433
516
|
}
|
|
434
517
|
|
|
435
518
|
@objc
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
FilterExpression,
|
|
6
|
+
BackgroundLayerStyleProps,
|
|
7
|
+
} from '../utils/MapboxStyles';
|
|
8
|
+
import { StyleValue } from '../utils/StyleValue';
|
|
9
|
+
|
|
10
|
+
import AbstractLayer from './AbstractLayer';
|
|
11
|
+
|
|
12
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
13
|
+
|
|
14
|
+
export type Props = {
|
|
15
|
+
/**
|
|
16
|
+
* A string that uniquely identifies the source in the style to which it is added.
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The source from which to obtain the data to style.
|
|
22
|
+
* If the source has not yet been added to the current style, the behavior is undefined.
|
|
23
|
+
* Inferred from parent source only if the layer is a direct child to it.
|
|
24
|
+
*/
|
|
25
|
+
sourceID?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
|
|
29
|
+
*/
|
|
30
|
+
sourceLayerID?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Inserts a layer above aboveLayerID.
|
|
34
|
+
*/
|
|
35
|
+
aboveLayerID?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Inserts a layer below belowLayerID
|
|
39
|
+
*/
|
|
40
|
+
belowLayerID?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Inserts a layer at a specified index
|
|
44
|
+
*/
|
|
45
|
+
layerIndex?: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Filter only the features in the source layer that satisfy a condition that you define
|
|
49
|
+
*/
|
|
50
|
+
filter?: FilterExpression;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The minimum zoom level at which the layer gets parsed and appears.
|
|
54
|
+
*/
|
|
55
|
+
minZoomLevel?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The maximum zoom level at which the layer gets parsed and appears.
|
|
59
|
+
*/
|
|
60
|
+
maxZoomLevel?: number;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Customizable style attributes
|
|
64
|
+
*/
|
|
65
|
+
style?: BackgroundLayerStyleProps;
|
|
66
|
+
} & React.ComponentProps<typeof AbstractLayer>;
|
|
67
|
+
|
|
68
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLBackgroundLayer';
|
|
69
|
+
|
|
70
|
+
type NativeTypeProps = Omit<Props, 'style'> & {
|
|
71
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
class BackgroundLayer extends AbstractLayer<Props, NativeTypeProps> {
|
|
75
|
+
static defaultProps = {
|
|
76
|
+
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
render() {
|
|
80
|
+
const props = {
|
|
81
|
+
...this.baseProps,
|
|
82
|
+
sourceLayerID: this.props.sourceLayerID,
|
|
83
|
+
};
|
|
84
|
+
return <RCTMGLBackgroundLayer ref={this.setNativeLayer} {...props} />;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const RCTMGLBackgroundLayer =
|
|
89
|
+
requireNativeComponent<NativeTypeProps>(NATIVE_MODULE_NAME);
|
|
90
|
+
|
|
91
|
+
export default BackgroundLayer;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
HostComponent,
|
|
4
|
+
NativeModules,
|
|
5
|
+
requireNativeComponent,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
|
|
8
|
+
import { FilterExpression, CircleLayerStyleProps } from '../utils/MapboxStyles';
|
|
9
|
+
import { StyleValue } from '../utils/StyleValue';
|
|
10
|
+
|
|
11
|
+
import AbstractLayer from './AbstractLayer';
|
|
12
|
+
|
|
13
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
14
|
+
|
|
15
|
+
export type Props = {
|
|
16
|
+
/**
|
|
17
|
+
* A string that uniquely identifies the source in the style to which it is added.
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The source from which to obtain the data to style.
|
|
23
|
+
* If the source has not yet been added to the current style, the behavior is undefined.
|
|
24
|
+
* Inferred from parent source only if the layer is a direct child to it.
|
|
25
|
+
*/
|
|
26
|
+
sourceID?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Identifier of the layer within the source identified by the sourceID property
|
|
30
|
+
* from which the receiver obtains the data to style.
|
|
31
|
+
*/
|
|
32
|
+
sourceLayerID?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Inserts a layer above aboveLayerID.
|
|
36
|
+
*/
|
|
37
|
+
aboveLayerID?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Inserts a layer below belowLayerID
|
|
41
|
+
*/
|
|
42
|
+
belowLayerID?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Inserts a layer at a specified index
|
|
46
|
+
*/
|
|
47
|
+
layerIndex?: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Filter only the features in the source layer that satisfy a condition that you define
|
|
51
|
+
*/
|
|
52
|
+
filter?: FilterExpression;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The minimum zoom level at which the layer gets parsed and appears.
|
|
56
|
+
*/
|
|
57
|
+
minZoomLevel?: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The maximum zoom level at which the layer gets parsed and appears.
|
|
61
|
+
*/
|
|
62
|
+
maxZoomLevel?: number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Customizable style attributes
|
|
66
|
+
*/
|
|
67
|
+
style?: CircleLayerStyleProps;
|
|
68
|
+
} & React.ComponentProps<typeof AbstractLayer>;
|
|
69
|
+
|
|
70
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLCircleLayer';
|
|
71
|
+
|
|
72
|
+
type NativeTypeProps = Omit<Props, 'style'> & {
|
|
73
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* CircleLayer is a style layer that renders one or more filled circles on the map.
|
|
78
|
+
*/
|
|
79
|
+
class CircleLayer extends AbstractLayer<Props, NativeTypeProps> {
|
|
80
|
+
static defaultProps = {
|
|
81
|
+
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
const props = {
|
|
86
|
+
...this.props,
|
|
87
|
+
...this.baseProps,
|
|
88
|
+
sourceLayerID: this.props.sourceLayerID,
|
|
89
|
+
};
|
|
90
|
+
return <RCTMGLCircleLayer ref={this.setNativeLayer} {...props} />;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const RCTMGLCircleLayer: HostComponent<Props> =
|
|
95
|
+
requireNativeComponent<NativeTypeProps>(NATIVE_MODULE_NAME);
|
|
96
|
+
|
|
97
|
+
export default CircleLayer;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
FilterExpression,
|
|
6
|
+
FillExtrusionLayerStyleProps,
|
|
7
|
+
} from '../utils/MapboxStyles';
|
|
8
|
+
import { StyleValue } from '../utils/StyleValue';
|
|
9
|
+
|
|
10
|
+
import AbstractLayer from './AbstractLayer';
|
|
11
|
+
|
|
12
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
13
|
+
|
|
14
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLFillExtrusionLayer';
|
|
15
|
+
|
|
16
|
+
export type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* A string that uniquely identifies the source in the style to which it is added.
|
|
19
|
+
*/
|
|
20
|
+
id: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The source from which to obtain the data to style.
|
|
24
|
+
* If the source has not yet been added to the current style, the behavior is undefined.
|
|
25
|
+
* Inferred from parent source only if the layer is a direct child to it.
|
|
26
|
+
*/
|
|
27
|
+
sourceID?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
|
|
31
|
+
*/
|
|
32
|
+
sourceLayerID?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Inserts a layer above aboveLayerID.
|
|
36
|
+
*/
|
|
37
|
+
aboveLayerID?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Inserts a layer below belowLayerID
|
|
41
|
+
*/
|
|
42
|
+
belowLayerID?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Inserts a layer at a specified index
|
|
46
|
+
*/
|
|
47
|
+
layerIndex?: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Filter only the features in the source layer that satisfy a condition that you define
|
|
51
|
+
*/
|
|
52
|
+
filter?: FilterExpression;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The minimum zoom level at which the layer gets parsed and appears.
|
|
56
|
+
*/
|
|
57
|
+
minZoomLevel: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The maximum zoom level at which the layer gets parsed and appears.
|
|
61
|
+
*/
|
|
62
|
+
maxZoomLevel: number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Customizable style attributes
|
|
66
|
+
*/
|
|
67
|
+
style?: FillExtrusionLayerStyleProps;
|
|
68
|
+
} & React.ComponentProps<typeof AbstractLayer>;
|
|
69
|
+
|
|
70
|
+
type NativeTypeProps = Omit<Props, 'style'> & {
|
|
71
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* FillExtrusionLayer is a style layer that renders one or more 3D extruded polygons on the map.
|
|
76
|
+
*/
|
|
77
|
+
class FillExtrusionLayer extends AbstractLayer<Props, NativeTypeProps> {
|
|
78
|
+
static defaultProps = {
|
|
79
|
+
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
render() {
|
|
83
|
+
const props = {
|
|
84
|
+
...this.props,
|
|
85
|
+
...this.baseProps,
|
|
86
|
+
sourceLayerID: this.props.sourceLayerID,
|
|
87
|
+
};
|
|
88
|
+
return <RCTMGLFillExtrusionLayer ref={this.setNativeLayer} {...props} />;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const RCTMGLFillExtrusionLayer =
|
|
93
|
+
requireNativeComponent<NativeTypeProps>(NATIVE_MODULE_NAME);
|
|
94
|
+
|
|
95
|
+
export default FillExtrusionLayer;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { FilterExpression, FillLayerStyleProps } from '../utils/MapboxStyles';
|
|
5
|
+
import { StyleValue } from '../utils/StyleValue';
|
|
6
|
+
|
|
7
|
+
import AbstractLayer from './AbstractLayer';
|
|
8
|
+
|
|
9
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
10
|
+
|
|
11
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLFillLayer';
|
|
12
|
+
|
|
13
|
+
export type Props = {
|
|
14
|
+
/**
|
|
15
|
+
* A string that uniquely identifies the source in the style to which it is added.
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The source from which to obtain the data to style.
|
|
21
|
+
* If the source has not yet been added to the current style, the behavior is undefined.
|
|
22
|
+
* Inferred from parent source only if the layer is a direct child to it.
|
|
23
|
+
*/
|
|
24
|
+
sourceID?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
|
|
28
|
+
*/
|
|
29
|
+
sourceLayerID?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Inserts a layer above aboveLayerID.
|
|
33
|
+
*/
|
|
34
|
+
aboveLayerID?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Inserts a layer below belowLayerID
|
|
38
|
+
*/
|
|
39
|
+
belowLayerID?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Inserts a layer at a specified index
|
|
43
|
+
*/
|
|
44
|
+
layerIndex?: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Filter only the features in the source layer that satisfy a condition that you define
|
|
48
|
+
*/
|
|
49
|
+
filter?: FilterExpression;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The minimum zoom level at which the layer gets parsed and appears.
|
|
53
|
+
*/
|
|
54
|
+
minZoomLevel?: number;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The maximum zoom level at which the layer gets parsed and appears.
|
|
58
|
+
*/
|
|
59
|
+
maxZoomLevel?: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Customizable style attributes
|
|
63
|
+
*/
|
|
64
|
+
style?: FillLayerStyleProps;
|
|
65
|
+
} & React.ComponentProps<typeof AbstractLayer>;
|
|
66
|
+
|
|
67
|
+
type NativeTypeProps = Omit<Props, 'style'> & {
|
|
68
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* FillLayer is a style layer that renders one or more filled (and optionally stroked) polygons on the map.
|
|
73
|
+
*/
|
|
74
|
+
class FillLayer extends AbstractLayer<Props, NativeTypeProps> {
|
|
75
|
+
static defaultProps = {
|
|
76
|
+
sourceID: MapboxGL.StyleSource.DefaultSourceID,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
render() {
|
|
80
|
+
const props = {
|
|
81
|
+
...this.baseProps,
|
|
82
|
+
sourceLayerID: this.props.sourceLayerID,
|
|
83
|
+
};
|
|
84
|
+
return <RCTMGLFillLayer ref={this.setNativeLayer} {...props} />;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const RCTMGLFillLayer =
|
|
89
|
+
requireNativeComponent<NativeTypeProps>(NATIVE_MODULE_NAME);
|
|
90
|
+
|
|
91
|
+
export default FillLayer;
|