@rnmapbox/maps 10.0.9-rc.1 → 10.0.10-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 +2 -1
- package/ios/RCTMGL-v10/RCTMGLAtmosphere.swift +3 -2
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +14 -5
- package/ios/RCTMGL-v10/RCTMGLImages.swift +2 -1
- package/ios/RCTMGL-v10/RCTMGLInteractiveElement.swift +3 -2
- package/ios/RCTMGL-v10/RCTMGLLayer.swift +2 -1
- package/ios/RCTMGL-v10/RCTMGLLight.swift +2 -1
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +53 -21
- package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +2 -1
- package/ios/RCTMGL-v10/RCTMGLNativeUserLocation.swift +4 -2
- package/ios/RCTMGL-v10/RCTMGLPointAnnotation.swift +2 -1
- package/ios/RCTMGL-v10/RCTMGLSource.swift +3 -2
- package/ios/RCTMGL-v10/RCTMGLTerrain.swift +3 -2
- package/package.json +1 -1
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -567,7 +567,8 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
567
567
|
fun applyLocalizeLabels() {
|
|
568
568
|
val localeStr = mLocaleString
|
|
569
569
|
if (localeStr != null) {
|
|
570
|
-
val locale = if (localeStr == "current") Locale.getDefault() else Locale(
|
|
570
|
+
val locale = if (localeStr == "current") Locale.getDefault() else Locale.Builder()
|
|
571
|
+
.setLanguageTag(localeStr).build()
|
|
571
572
|
savedStyle?.localizeLabels(locale, mLocaleLayerIds)
|
|
572
573
|
}
|
|
573
574
|
}
|
|
@@ -17,15 +17,16 @@ class RCTMGLAtmosphere : RCTMGLSingletonLayer, RCTMGLMapComponent, RCTMGLSourceC
|
|
|
17
17
|
addStylesAndUpdate()
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
20
|
+
func removeFromMap(_ map: RCTMGLMapView, reason _: RemovalReason) -> Bool {
|
|
21
21
|
self.map = nil
|
|
22
22
|
|
|
23
23
|
guard let mapboxMap = map.mapboxMap else {
|
|
24
|
-
return
|
|
24
|
+
return false
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
let style = mapboxMap.style
|
|
28
28
|
removeFromMap(map, style: style)
|
|
29
|
+
return true
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
func waitForStyleLoad() -> Bool {
|
|
@@ -2,9 +2,13 @@ import Foundation
|
|
|
2
2
|
import MapboxMaps
|
|
3
3
|
import Turf
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
enum RemovalReason {
|
|
6
|
+
case ViewRemoval, StyleChange, OnDestory, ComponentChange, Reorder
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
protocol RCTMGLMapComponent: AnyObject {
|
|
6
10
|
func addToMap(_ map: RCTMGLMapView, style: Style)
|
|
7
|
-
func removeFromMap(_ map: RCTMGLMapView)
|
|
11
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool
|
|
8
12
|
|
|
9
13
|
func waitForStyleLoad() -> Bool
|
|
10
14
|
}
|
|
@@ -98,9 +102,10 @@ open class RCTMGLMapComponentBase : UIView, RCTMGLMapComponent {
|
|
|
98
102
|
_map = map
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
105
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
102
106
|
_mapCallbacks = []
|
|
103
107
|
_map = nil
|
|
108
|
+
return true
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
|
|
@@ -506,9 +511,13 @@ class RCTMGLCamera : RCTMGLMapComponentBase {
|
|
|
506
511
|
map.reactCamera = self
|
|
507
512
|
}
|
|
508
513
|
|
|
509
|
-
override func removeFromMap(_ map: RCTMGLMapView) {
|
|
514
|
+
override func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
515
|
+
if (reason == .StyleChange) {
|
|
516
|
+
return false
|
|
517
|
+
}
|
|
518
|
+
|
|
510
519
|
map.viewport.removeStatusObserver(self)
|
|
511
|
-
super.removeFromMap(map)
|
|
520
|
+
return super.removeFromMap(map, reason:reason)
|
|
512
521
|
}
|
|
513
522
|
}
|
|
514
523
|
|
|
@@ -61,9 +61,10 @@ class RCTMGLImages : UIView, RCTMGLMapComponent {
|
|
|
61
61
|
self.addImageViews(style: style, imageViews: imageViews)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
64
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
65
65
|
self.style = nil
|
|
66
66
|
// v10todo
|
|
67
|
+
return true
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
func addRemoteImages(style: Style, remoteImages: [String: Any]) {
|
|
@@ -19,7 +19,7 @@ class RCTMGLInteractiveElement : UIView, RCTMGLMapComponent {
|
|
|
19
19
|
willSet {
|
|
20
20
|
if id != nil && newValue != id {
|
|
21
21
|
Logger.log(level:.warn, message: "Changing id from: \(optional: id) to \(optional: newValue), changing of id is supported")
|
|
22
|
-
if let map = map { removeFromMap(map) }
|
|
22
|
+
if let map = map { removeFromMap(map, reason: .ComponentChange) }
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
didSet {
|
|
@@ -53,8 +53,9 @@ class RCTMGLInteractiveElement : UIView, RCTMGLMapComponent {
|
|
|
53
53
|
self.map = map
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
56
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
57
57
|
self.map = nil
|
|
58
|
+
return true
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
func waitForStyleLoad() -> Bool {
|
|
@@ -276,8 +276,9 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
279
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
280
280
|
removeFromMap(map.mapboxMap.style)
|
|
281
|
+
return true
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
private func removeFromMap(_ style: Style) {
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
import Turf
|
|
3
3
|
import MapKit
|
|
4
4
|
|
|
5
|
+
class FeatureEntry {
|
|
6
|
+
let feature: RCTMGLMapComponent
|
|
7
|
+
let view: UIView
|
|
8
|
+
var addedToMap: Bool = false
|
|
9
|
+
|
|
10
|
+
init(feature:RCTMGLMapComponent, view: UIView, addedToMap: Bool = false) {
|
|
11
|
+
self.feature = feature
|
|
12
|
+
self.view = view
|
|
13
|
+
self.addedToMap = addedToMap
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
class RCTMGLCameraChanged : RCTMGLEvent, RCTEvent {
|
|
6
18
|
init(type: EventType, payload: [String:Any?]?, reactTag: NSNumber) {
|
|
7
19
|
super.init(type: type, payload: payload)
|
|
@@ -54,9 +66,8 @@ open class RCTMGLMapView : MapView {
|
|
|
54
66
|
|
|
55
67
|
var styleLoaded: Bool = false
|
|
56
68
|
var styleLoadWaiters : [(MapboxMap)->Void] = []
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var componentsToRefreshOnStyleChange: [RCTMGLMapComponent] = []
|
|
69
|
+
|
|
70
|
+
var features: [FeatureEntry] = []
|
|
60
71
|
|
|
61
72
|
weak var reactCamera : RCTMGLCamera?
|
|
62
73
|
var images : [RCTMGLImages] = []
|
|
@@ -89,16 +100,21 @@ open class RCTMGLMapView : MapView {
|
|
|
89
100
|
func addToMap(_ subview: UIView) {
|
|
90
101
|
if let mapComponent = subview as? RCTMGLMapComponent {
|
|
91
102
|
let style = mapView.mapboxMap.style
|
|
103
|
+
var addToMap = false
|
|
92
104
|
if mapComponent.waitForStyleLoad() {
|
|
93
|
-
componentsToRefreshOnStyleChange.append(mapComponent)
|
|
94
105
|
if (self.styleLoaded) {
|
|
95
|
-
|
|
96
|
-
} else {
|
|
97
|
-
onStyleLoadedComponents.append(mapComponent)
|
|
106
|
+
addToMap = true
|
|
98
107
|
}
|
|
99
108
|
} else {
|
|
109
|
+
addToMap = true
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let entry = FeatureEntry(feature: mapComponent, view: subview, addedToMap: false)
|
|
113
|
+
if (addToMap) {
|
|
100
114
|
mapComponent.addToMap(self, style: style)
|
|
115
|
+
entry.addedToMap = true
|
|
101
116
|
}
|
|
117
|
+
features.append(entry)
|
|
102
118
|
} else {
|
|
103
119
|
subview.reactSubviews()?.forEach { addToMap($0) }
|
|
104
120
|
}
|
|
@@ -109,11 +125,15 @@ open class RCTMGLMapView : MapView {
|
|
|
109
125
|
|
|
110
126
|
func removeFromMap(_ subview: UIView) {
|
|
111
127
|
if let mapComponent = subview as? RCTMGLMapComponent {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
var entryIndex = features.firstIndex { $0.view == subview }
|
|
129
|
+
if let entryIndex = entryIndex {
|
|
130
|
+
var entry = features[entryIndex]
|
|
131
|
+
if (entry.addedToMap) {
|
|
132
|
+
mapComponent.removeFromMap(self, reason: .OnDestory)
|
|
133
|
+
entry.addedToMap = false
|
|
134
|
+
}
|
|
135
|
+
features.remove(at: entryIndex)
|
|
115
136
|
}
|
|
116
|
-
mapComponent.removeFromMap(self)
|
|
117
137
|
} else {
|
|
118
138
|
subview.reactSubviews()?.forEach { removeFromMap($0) }
|
|
119
139
|
}
|
|
@@ -321,17 +341,31 @@ open class RCTMGLMapView : MapView {
|
|
|
321
341
|
@objc func setReactPitchEnabled(_ value: Bool) {
|
|
322
342
|
self.mapView.gestures.options.pitchEnabled = value
|
|
323
343
|
}
|
|
344
|
+
|
|
345
|
+
private func removeAllFeaturesFromMap(reason: RemovalReason) {
|
|
346
|
+
features.forEach { entry in
|
|
347
|
+
if (entry.addedToMap) {
|
|
348
|
+
entry.feature.removeFromMap(self, reason: reason)
|
|
349
|
+
entry.addedToMap = false
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private func addFeaturesToMap(style: Style) {
|
|
355
|
+
features.forEach { entry in
|
|
356
|
+
if (!entry.addedToMap) {
|
|
357
|
+
entry.feature.addToMap(self, style: style)
|
|
358
|
+
entry.addedToMap = true
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
324
362
|
|
|
325
363
|
func refreshComponentsBeforeStyleChange() {
|
|
326
|
-
|
|
327
|
-
$0.removeFromMap(self)
|
|
328
|
-
}
|
|
364
|
+
removeAllFeaturesFromMap(reason: .StyleChange)
|
|
329
365
|
}
|
|
330
366
|
|
|
331
367
|
func refreshComponentsAfterStyleChange(style: Style) {
|
|
332
|
-
|
|
333
|
-
$0.addToMap(self, style: style)
|
|
334
|
-
}
|
|
368
|
+
addFeaturesToMap(style: style)
|
|
335
369
|
}
|
|
336
370
|
|
|
337
371
|
@objc func setReactStyleURL(_ value: String?) {
|
|
@@ -353,7 +387,7 @@ open class RCTMGLMapView : MapView {
|
|
|
353
387
|
}
|
|
354
388
|
if !initialLoad {
|
|
355
389
|
self.onNext(event: .styleLoaded) {_,_ in
|
|
356
|
-
self.
|
|
390
|
+
self.addFeaturesToMap(style: self.mapboxMap.style)
|
|
357
391
|
}
|
|
358
392
|
}
|
|
359
393
|
}
|
|
@@ -557,9 +591,7 @@ extension RCTMGLMapView {
|
|
|
557
591
|
})
|
|
558
592
|
|
|
559
593
|
self.onEvery(event: .styleLoaded, handler: { (self, event) in
|
|
560
|
-
self.
|
|
561
|
-
component.addToMap(self, style: self.mapboxMap.style)
|
|
562
|
-
}
|
|
594
|
+
self.addFeaturesToMap(style: self.mapboxMap.style)
|
|
563
595
|
|
|
564
596
|
if !self.styleLoaded {
|
|
565
597
|
self.styleLoaded = true
|
|
@@ -108,8 +108,9 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
108
108
|
add()
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
111
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
112
112
|
remove()
|
|
113
|
+
return true
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
// MARK: - React methods
|
|
@@ -30,14 +30,16 @@ class RCTMGLNativeUserLocation : UIView, RCTMGLMapComponent {
|
|
|
30
30
|
_applySettings(map)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
33
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
34
34
|
map.location.options.puckType = nil
|
|
35
35
|
guard let mapboxMap = map.mapboxMap else {
|
|
36
|
-
return
|
|
36
|
+
return true
|
|
37
37
|
}
|
|
38
38
|
let style = mapboxMap.style
|
|
39
39
|
map.location.options.puckType = .none
|
|
40
40
|
self.map = nil
|
|
41
|
+
|
|
42
|
+
return true
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
func waitForStyleLoad() -> Bool {
|
|
@@ -212,9 +212,10 @@ class RCTMGLPointAnnotation : RCTMGLInteractiveElement {
|
|
|
212
212
|
addIfPossible()
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
override func removeFromMap(_ map: RCTMGLMapView) {
|
|
215
|
+
override func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
216
216
|
removeIfAdded()
|
|
217
217
|
self.map = nil
|
|
218
|
+
return true
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
// MARK: - RCTMGLInteractiveElement
|
|
@@ -54,7 +54,7 @@ class RCTMGLSource : RCTMGLInteractiveElement {
|
|
|
54
54
|
layers.removeAll { $0 as AnyObject === layer }
|
|
55
55
|
} else if let component = subview as? RCTMGLMapComponent {
|
|
56
56
|
if let map = map {
|
|
57
|
-
component.removeFromMap(map)
|
|
57
|
+
component.removeFromMap(map, reason: .ViewRemoval)
|
|
58
58
|
}
|
|
59
59
|
layers.removeAll { $0 as AnyObject === component }
|
|
60
60
|
}
|
|
@@ -95,7 +95,7 @@ class RCTMGLSource : RCTMGLInteractiveElement {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
override func removeFromMap(_ map: RCTMGLMapView) {
|
|
98
|
+
override func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
99
99
|
self.map = nil
|
|
100
100
|
|
|
101
101
|
for layer in self.layers {
|
|
@@ -109,5 +109,6 @@ class RCTMGLSource : RCTMGLInteractiveElement {
|
|
|
109
109
|
}
|
|
110
110
|
self.ownsSource = false
|
|
111
111
|
}
|
|
112
|
+
return true
|
|
112
113
|
}
|
|
113
114
|
}
|
|
@@ -22,15 +22,16 @@ class RCTMGLTerrain : RCTMGLSingletonLayer, RCTMGLMapComponent, RCTMGLSourceCons
|
|
|
22
22
|
addStylesAndUpdate()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
func removeFromMap(_ map: RCTMGLMapView) {
|
|
25
|
+
func removeFromMap(_ map: RCTMGLMapView, reason: RemovalReason) -> Bool {
|
|
26
26
|
self.map = nil
|
|
27
27
|
|
|
28
28
|
guard let mapboxMap = map.mapboxMap else {
|
|
29
|
-
return
|
|
29
|
+
return true
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
let style = mapboxMap.style
|
|
33
33
|
removeFromMap(map, style: style)
|
|
34
|
+
return true
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
func waitForStyleLoad() -> Bool {
|