@rnmapbox/maps 10.0.0-beta.43 → 10.0.0-beta.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/android/install.md +49 -1
  2. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/components/camera/CameraStop.java +4 -4
  3. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java +3 -3
  4. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +1 -1
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +0 -2
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +162 -51
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewManager.kt +10 -0
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +6 -6
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +11 -7
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +22 -2
  11. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +17 -19
  12. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyle.kt +1 -1
  13. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +1 -1
  14. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/DownloadMapImageTask.kt +2 -1
  15. package/docs/MapboxGL.md +1 -1
  16. package/docs/MarkerView.md +17 -10
  17. package/docs/PointAnnotation.md +1 -1
  18. package/docs/ShapeSource.md +13 -9
  19. package/docs/SymbolLayer.md +1 -1
  20. package/docs/docs.json +145 -161
  21. package/index.d.ts +7 -56
  22. package/ios/RCTMGL-v10/RCTLog.swift +5 -5
  23. package/ios/RCTMGL-v10/RCTMGLCamera.swift +2 -2
  24. package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +2 -2
  25. package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +186 -105
  26. package/ios/RCTMGL-v10/RCTMGLMarkerViewManager.m +2 -1
  27. package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.swift +1 -1
  28. package/ios/RCTMGL-v10/RCTMGLUtils.swift +1 -1
  29. package/ios/RCTMGL-v10/RCTMGLVectorLayer.swift +1 -1
  30. package/ios/install.md +3 -2
  31. package/javascript/components/AbstractLayer.tsx +9 -6
  32. package/javascript/components/AbstractSource.tsx +23 -0
  33. package/javascript/components/HeadingIndicator.tsx +1 -1
  34. package/javascript/components/Images.js +1 -1
  35. package/javascript/components/MapView.js +5 -2
  36. package/javascript/components/MarkerView.tsx +81 -76
  37. package/javascript/components/NativeBridgeComponent.tsx +20 -14
  38. package/javascript/components/PointAnnotation.tsx +3 -2
  39. package/javascript/components/RasterSource.js +1 -1
  40. package/javascript/components/ShapeSource.tsx +412 -0
  41. package/javascript/components/Style.js +2 -2
  42. package/javascript/components/SymbolLayer.tsx +3 -5
  43. package/javascript/components/VectorSource.js +6 -3
  44. package/javascript/components/annotations/Annotation.js +1 -1
  45. package/javascript/index.js +2 -2
  46. package/javascript/utils/animated/Animated.js +2 -2
  47. package/javascript/utils/deprecation.ts +7 -4
  48. package/javascript/utils/filterUtils.tsx +1 -1
  49. package/javascript/utils/index.d.ts +19 -6
  50. package/package.json +1 -1
  51. package/scripts/autogenHelpers/DocJSONBuilder.js +17 -1
  52. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapper.kt +0 -8
  53. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapperManager.kt +0 -21
  54. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapper.swift +0 -24
  55. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.m +0 -8
  56. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.swift +0 -14
  57. package/javascript/components/AbstractSource.js +0 -15
  58. package/javascript/components/ShapeSource.js +0 -373
package/index.d.ts CHANGED
@@ -43,6 +43,10 @@ import {
43
43
  SymbolLayer as _SymbolLayer,
44
44
  Props as _SymbolLayerProps,
45
45
  } from './javascript/components/SymbolLayer';
46
+ import {
47
+ ShapeSource as _ShapeSource,
48
+ Props as _ShapeSourceProps,
49
+ } from './javascript/components/ShapeSource';
46
50
  import type {
47
51
  MapboxGLEvent as _MapboxGLEvent,
48
52
  AnimatedPoint as _AnimatedPoint,
@@ -148,6 +152,8 @@ declare namespace MapboxGL {
148
152
  const MarkerView = _MarkerView;
149
153
  const PointAnnotation = _PointAnnotation;
150
154
  const SymbolLayer = _SymbolLayer;
155
+ const ShapeSource = _ShapeSource;
156
+ type ShapeSource = _ShapeSource;
151
157
 
152
158
  type MapboxGLEvent = _MapboxGLEvent;
153
159
  type UserTrackingMode = _UserTrackingMode;
@@ -244,7 +250,7 @@ declare namespace MapboxGL {
244
250
 
245
251
  namespace Animated {
246
252
  // sources
247
- class ShapeSource extends Component<ShapeSourceProps> {}
253
+ class ShapeSource extends Component<_ShapeSourceProps> {}
248
254
  class ImageSource extends Component<ImageSourceProps> {}
249
255
 
250
256
  // layers
@@ -364,33 +370,6 @@ declare namespace MapboxGL {
364
370
  * Sources
365
371
  */
366
372
  class VectorSource extends Component<VectorSourceProps> {}
367
- class ShapeSource extends Component<ShapeSourceProps> {
368
- features(
369
- filter?: Expression,
370
- ): Promise<FeatureCollection<Geometry, Properties>>;
371
-
372
- getClusterExpansionZoom(
373
- feature: Feature<Geometry, Properties> | number,
374
- ): Promise<number>;
375
- /**
376
- * Returns all the leaves of a cluster with pagination support.
377
- * @param cluster feature cluster
378
- * @param limit the number of leaves to return
379
- * @param offset the amount of points to skip (for pagination)
380
- */
381
- getClusterLeaves: (
382
- feature: Feature<Geometry, Properties> | number,
383
- limit: number,
384
- offset: number,
385
- ) => Promise<FeatureCollection<Geometry, Properties>>;
386
- /**
387
- * Returns the children of a cluster (on the next zoom level).
388
- * @param cluster feature cluster
389
- */
390
- getClusterChildren: (
391
- feature: Feature<Geometry, Properties> | number,
392
- ) => Promise<FeatureCollection<Geometry, Properties>>;
393
- }
394
373
  class RasterSource extends Component<RasterSourceProps> {}
395
374
  class RasterDemSource extends Component<RasterSourceProps> {}
396
375
 
@@ -810,30 +789,6 @@ export interface VectorSourceProps extends TileSourceProps {
810
789
  };
811
790
  }
812
791
 
813
- export interface ShapeSourceProps extends ViewProps {
814
- id: string;
815
- url?: string;
816
- shape?:
817
- | GeoJSON.GeometryCollection
818
- | GeoJSON.Feature
819
- | GeoJSON.FeatureCollection
820
- | GeoJSON.Geometry;
821
- cluster?: boolean;
822
- clusterRadius?: number;
823
- clusterMaxZoomLevel?: number;
824
- clusterProperties?: object;
825
- maxZoomLevel?: number;
826
- buffer?: number;
827
- tolerance?: number;
828
- lineMetrics?: boolean;
829
- images?: { assets?: string[] } & { [key: string]: ImageSourcePropType };
830
- onPress?: (event: OnPressEvent) => void;
831
- hitbox?: {
832
- width: number;
833
- height: number;
834
- };
835
- }
836
-
837
792
  export interface RasterSourceProps extends TileSourceProps {
838
793
  tileSize?: number;
839
794
  }
@@ -875,10 +830,6 @@ export interface RasterLayerProps extends LayerBaseProps {
875
830
  style?: StyleProp<RasterLayerStyle>;
876
831
  }
877
832
 
878
- export interface SymbolLayerProps extends LayerBaseProps {
879
- style?: SymbolLayerStyleProps;
880
- }
881
-
882
833
  export interface HeatmapLayerProps extends LayerBaseProps {
883
834
  style?: StyleProp<HeatmapLayerStyle>;
884
835
  }
@@ -1,19 +1,19 @@
1
- func RCTLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
1
+ func RCTMGLLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
2
2
  RCTMGLSwiftLog.error(message, file: file, line: line)
3
3
  }
4
4
 
5
- func RCTLogWarn(_ message: String, _ file: String=#file, _ line: UInt=#line) {
5
+ func RCTMGLLogWarn(_ message: String, _ file: String=#file, _ line: UInt=#line) {
6
6
  RCTMGLSwiftLog.warn(message, file: file, line: line)
7
7
  }
8
8
 
9
- func RCTLogInfo(_ message: String, _ file: String=#file, _ line: UInt=#line) {
9
+ func RCTMGLLogInfo(_ message: String, _ file: String=#file, _ line: UInt=#line) {
10
10
  RCTMGLSwiftLog.info(message, file: file, line: line)
11
11
  }
12
12
 
13
- func RCTLog(_ message: String, _ file: String=#file, _ line: UInt=#line) {
13
+ func RCTMGLLog(_ message: String, _ file: String=#file, _ line: UInt=#line) {
14
14
  RCTMGLSwiftLog.log(message, file: file, line: line)
15
15
  }
16
16
 
17
- func RCTLogTrace(_ message: String, _ file: String=#file, _ line: UInt=#line) {
17
+ func RCTMGLLogTrace(_ message: String, _ file: String=#file, _ line: UInt=#line) {
18
18
  RCTMGLSwiftLog.trace(message, file: file, line: line)
19
19
  }
@@ -14,7 +14,7 @@ enum CameraMode: String, CaseIterable {
14
14
  }
15
15
 
16
16
  enum UserTrackingMode: String {
17
- case none,compass, course, normal
17
+ case none, compass, course, normal
18
18
  }
19
19
 
20
20
  struct CameraUpdateItem {
@@ -188,7 +188,7 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
188
188
 
189
189
  func _updateCameraFromTrackingMode() {
190
190
  withMapView { map in
191
- let userTrackingMode = UserTrackingMode(rawValue: self.followUserMode ?? "none")
191
+ let userTrackingMode = UserTrackingMode(rawValue: self.followUserMode ?? UserTrackingMode.normal.rawValue)
192
192
  guard let userTrackingMode = userTrackingMode else {
193
193
  Logger.error("RCTMGLCamera: Unexpected followUserMode \(optional: self.followUserMode)")
194
194
  self._disableUsetTracking(map)
@@ -30,7 +30,7 @@ extension RCTMGLMapViewManager {
30
30
  let view = viewRegistry![reactTag]
31
31
 
32
32
  guard let view = view! as? RCTMGLMapView else {
33
- RCTLogError("Invalid react tag, could not find RCTMGLMapView");
33
+ RCTMGLLogError("Invalid react tag, could not find RCTMGLMapView");
34
34
  rejecter(name, "Unknown find reactTag: \(reactTag)", nil)
35
35
  return;
36
36
  }
@@ -47,7 +47,7 @@ extension RCTMGLMapViewManager {
47
47
  {
48
48
  withMapView(reactTag, name: name, rejecter: rejecter) { view in
49
49
  guard let mapboxMap = view.mapboxMap else {
50
- RCTLogError("MapboxMap is not yet available");
50
+ RCTMGLLogError("MapboxMap is not yet available");
51
51
  rejecter(name, "Map not loaded yet", nil)
52
52
  return;
53
53
  }
@@ -1,152 +1,233 @@
1
1
  import MapboxMaps
2
+ import UIKit
2
3
 
3
- class RCTMGLMarkerView : UIView, RCTMGLMapComponent {
4
+ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
5
+ // MARK: - Instance variables
6
+
4
7
  static let key = "RCTMGLMarkerView"
8
+ let id: String = "marker-\(UUID().uuidString)"
5
9
 
6
- var map: RCTMGLMapView? = nil
10
+ var map: RCTMGLMapView?
7
11
 
8
- // MARK: - react view
9
- var reactSubviews : [UIView] = []
10
-
11
- @objc
12
- override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
13
- if subview is RCTMGLCallout {
14
- Logger.log(level: .warn, message: "MarkerView doesn't supports callouts")
15
- }
16
- reactSubviews.insert(subview, at: atIndex)
17
- if reactSubviews.count > 1 {
18
- Logger.log(level: .error, message: "MarkerView supports max 1 subview")
12
+ var didAddToMap = false
13
+
14
+ @objc var coordinate: String? {
15
+ didSet {
16
+ update()
19
17
  }
20
18
  }
21
-
22
- @objc
23
- override func removeReactSubview(_ subview: UIView!) {
24
- reactSubviews.removeAll(where: { $0 == subview })
25
- }
26
19
 
27
- func view() -> UIView? {
28
- return reactSubviews.first
20
+ @objc var anchor: [String: NSNumber]? {
21
+ didSet {
22
+ update()
23
+ }
29
24
  }
30
25
 
31
- // MARK: - RCTMGLMapComponent
32
-
33
- func waitForStyleLoad() -> Bool {
34
- return true
26
+ @objc var allowOverlap: Bool = false {
27
+ didSet {
28
+ update()
29
+ }
35
30
  }
36
31
 
37
- func addToMap(_ map: RCTMGLMapView, style: Style) {
38
- logged("RCTMGLMarkerView.addToMap") {
39
- self.map = map
40
- let point = try point()
41
-
42
- try point.coordinates.validate()
43
-
44
- guard let view = view() else {
45
- Logger.log(level: .error, message: "MarkerView: No subview to render")
46
- return
32
+ @objc var isSelected: Bool = false {
33
+ didSet {
34
+ let hasBecomeSelected = isSelected && !oldValue
35
+
36
+ if hasBecomeSelected {
37
+ setSelected()
38
+ } else {
39
+ update()
47
40
  }
48
- let bounds = view.bounds
49
- view.isHidden = true
50
- try viewAnnotations()?.add(view, options: ViewAnnotationOptions.init(geometry: Geometry.point(point), width: bounds.width, height: bounds.height, associatedFeatureId: nil, allowOverlap: true, anchor: .center, offsetX: 0, offsetY: 0, selected: false))
51
41
  }
52
42
  }
43
+
44
+ // MARK: - Derived variables
53
45
 
54
- func viewAnnotations() -> ViewAnnotationManager? {
46
+ var annotationManager: ViewAnnotationManager? {
55
47
  self.map?.viewAnnotations
56
48
  }
57
49
 
58
- func removeFromMap(_ map: RCTMGLMapView) {
59
- guard let view = view() else {
60
- Logger.log(level: .error, message: "MarkerView: No subview to render")
61
- return
50
+ var point: Point? {
51
+ guard let _coordinate = coordinate else {
52
+ Logger.log(level: .error, message: "[getPoint] No coordinates were set")
53
+ return nil
62
54
  }
63
- viewAnnotations()?.remove(view)
55
+
56
+ guard let _data = _coordinate.data(using: .utf8) else {
57
+ Logger.log(level: .error, message: "[getPoint] Cannot serialize coordinate")
58
+ return nil
59
+ }
60
+
61
+ guard let _feature = try? JSONDecoder().decode(Feature.self, from: _data) else {
62
+ Logger.log(level: .error, message: "[getPoint] Cannot parse serialized coordinate")
63
+ return nil
64
+ }
65
+
66
+ guard let _geometry = _feature.geometry else {
67
+ Logger.log(level: .error, message: "[getPoint] Invalid geometry")
68
+ return nil
69
+ }
70
+
71
+ guard case .point(let _point) = _geometry else {
72
+ Logger.log(level: .error, message: "[getPoint] Invalid point")
73
+ return nil
74
+ }
75
+
76
+ return _point
77
+ }
78
+
79
+ // MARK: - RCTMGLMapComponent methods
80
+
81
+ func addToMap(_ map: RCTMGLMapView, style: Style) {
64
82
  self.map = map
83
+ add()
65
84
  }
66
-
67
- override func reactSetFrame(_ frame: CGRect) {
68
- super.reactSetFrame(frame)
69
85
 
70
- _updateFrameOrAnchor()
86
+ func removeFromMap(_ map: RCTMGLMapView) {
87
+ remove()
71
88
  }
72
89
 
73
- @objc var coordinate : String? {
74
- didSet {
75
- _updateCoordinate()
90
+ // MARK: - React methods
91
+
92
+ override func reactSetFrame(_ frame: CGRect) {
93
+ let prev = self.frame
94
+ var next = frame
95
+
96
+ let frameDidChange = !next.equalTo(prev)
97
+ if (frameDidChange) {
98
+ if prev.minX == 0 || prev.minY == 0 {
99
+ // Start the view offscreen to make it invisible until the annotation manager sets it to
100
+ // the correct point on the map.
101
+ next = CGRect(
102
+ x: -10000,
103
+ y: -10000,
104
+ width: next.width,
105
+ height: next.height
106
+ )
107
+ } else {
108
+ // Calculate the next position to temporarily place the view before the annotation manager
109
+ // sets it to the correct point on the map.
110
+ let dx = (next.width - prev.width) / 2
111
+ let dy = (next.height - prev.height) / 2
112
+ next = CGRect(
113
+ x: prev.minX - dx,
114
+ y: prev.minY - dy,
115
+ width: next.width,
116
+ height: next.height
117
+ )
118
+ }
76
119
  }
120
+
121
+ super.reactSetFrame(next)
122
+ addOrUpdate()
77
123
  }
78
124
 
79
- @objc var anchor : [String:NSNumber]? {
80
- didSet {
81
- _updateFrameOrAnchor()
82
- }
125
+ override func insertReactSubview(_ subview: UIView, at atIndex: Int) {
126
+ super.insertReactSubview(subview, at: atIndex)
83
127
  }
84
128
 
85
- func point() throws -> Point {
86
- guard let coordinate = coordinate else {
87
- throw RCTMGLError.failed("no coordinates were set")
88
- }
89
-
90
- guard let data = coordinate.data(using: .utf8) else {
91
- throw RCTMGLError.failed("cannot serialize coordiante")
92
- }
93
-
94
- guard let feature = try? JSONDecoder().decode(Feature.self, from: data) else {
95
- throw RCTMGLError.failed("cannot parse serialized coordiante")
96
- }
97
-
98
- guard let geometry : Geometry = feature.geometry else {
99
- throw RCTMGLError.failed("is not a geometry")
100
- }
129
+ override func removeReactSubview(_ subview: UIView) {
130
+ super.removeReactSubview(subview)
131
+ }
132
+
133
+ func waitForStyleLoad() -> Bool {
134
+ true
135
+ }
101
136
 
102
- guard case .point(let point) = geometry else {
103
- throw RCTMGLError.failed("is not a point")
104
- }
137
+ // MARK: - Create, update, and remove methods
105
138
 
106
- return point
107
- }
139
+ private func addOrUpdate() {
140
+ if didAddToMap {
141
+ update()
142
+ } else {
143
+ add()
144
+ }
145
+ }
108
146
 
109
- func _updateCoordinate() {
110
- guard let view = view() else {
147
+ /// Because the necessary data to add an annotation arrives from different sources at unpredictable times, we let the arrival of each value trigger an attempt to add the annotation, which we only do if all of the data exists, and the annotation not been added already.
148
+ private func add() {
149
+ if didAddToMap {
111
150
  return
112
151
  }
113
152
 
114
- logged("MarkerView.updateCoordinate") {
115
- let point = try point()
153
+ guard let annotationManager = annotationManager, let _ = point else {
154
+ return
155
+ }
116
156
 
117
- try viewAnnotations()?.update(view, options: ViewAnnotationOptions(geometry: Geometry.point(point)))
157
+ do {
158
+ let options = getOptions()
159
+ try annotationManager.add(self, id: id, options: options)
160
+ didAddToMap = true
161
+ } catch {
162
+ Logger.log(level: .error, message: "[MarkerView] Error adding annotation", error: error)
118
163
  }
119
164
  }
120
-
121
- func _updateFrameOrAnchor() {
122
- guard let view = view() else {
165
+
166
+ private func update() {
167
+ if !didAddToMap {
123
168
  return
124
169
  }
125
- var options = ViewAnnotationOptions()
126
- let defaultX : CGFloat = 0.5
127
- let defaultY : CGFloat = 0.5
128
- let bounds = view.bounds
129
- options.width = bounds.width
130
- options.height = bounds.height
131
170
 
132
- if let anchor = anchor {
133
- if let anchorX = anchor["x"] {
134
- options.offsetX = bounds.width * (CGFloat(anchorX.floatValue) - defaultX)
135
- }
136
- if let anchorY = anchor["y"] {
137
- options.offsetY = bounds.height * (CGFloat(anchorY.floatValue) - defaultY)
138
- }
139
- if let view = view as? RCTMGLMarkerViewWrapper {
140
- if let anchorX = anchor["x"] {
141
- view.anchorX = CGFloat(anchorX.floatValue)
142
- }
143
- if let anchorY = anchor["y"] {
144
- view.anchorY = CGFloat(anchorY.floatValue)
145
- }
171
+ guard let annotationManager = annotationManager else {
172
+ return
173
+ }
174
+
175
+ do {
176
+ let options = getOptions()
177
+ try annotationManager.update(self, options: options)
178
+ } catch {
179
+ Logger.log(level: .error, message: "[MarkerView] Error updating annotation", error: error)
180
+ }
181
+ }
182
+
183
+ /// There is a Mapbox bug where `selected` does not cause the marker to move to the front, so we can't simply update the component.
184
+ /// This forces that effect. See https://github.com/mapbox/mapbox-maps-ios/issues/1599.
185
+ private func setSelected() {
186
+ if let options = annotationManager?.options(for: self) {
187
+ do {
188
+ annotationManager?.remove(self)
189
+ try annotationManager?.add(self, id: id, options: options)
190
+ } catch {
191
+ Logger.log(level: .error, message: "[MarkerView] Error selecting annotation", error: error)
146
192
  }
147
193
  }
148
- logged("MarkerView.updateFrame") {
149
- try viewAnnotations()?.update(view, options: options)
194
+ }
195
+
196
+ private func remove() {
197
+ annotationManager?.remove(self)
198
+ }
199
+
200
+ // MARK: - Helper functions
201
+
202
+ private func getOptions() -> ViewAnnotationOptions {
203
+ var geometry: GeometryConvertible?
204
+ if let point = point {
205
+ geometry = Geometry.point(point)
150
206
  }
207
+
208
+ let offset = getOffset()
209
+
210
+ let options = ViewAnnotationOptions(
211
+ geometry: geometry,
212
+ width: self.bounds.width,
213
+ height: self.bounds.height,
214
+ allowOverlap: allowOverlap,
215
+ offsetX: offset.dx,
216
+ offsetY: offset.dy
217
+ )
218
+ return options
219
+ }
220
+
221
+ private func getOffset() -> CGVector {
222
+ guard let anchor = anchor, let anchorX = anchor["x"]?.CGFloat, let anchorY = anchor["y"]?.CGFloat else {
223
+ return .zero
224
+ }
225
+
226
+ // Create a modified offset, normalized from 0..1 to -1..1 and scaled to
227
+ // the view size.
228
+ let x = (anchorX * 2 - 1) * (self.bounds.width / 2) * -1
229
+ let y = (anchorY * 2 - 1) * (self.bounds.height / 2)
230
+
231
+ return CGVector(dx: x, dy: y)
151
232
  }
152
233
  }
@@ -6,6 +6,7 @@
6
6
 
7
7
  RCT_EXPORT_VIEW_PROPERTY(coordinate, NSString)
8
8
  RCT_EXPORT_VIEW_PROPERTY(anchor, NSDictionary)
9
+ RCT_EXPORT_VIEW_PROPERTY(allowOverlap, BOOL)
10
+ RCT_EXPORT_VIEW_PROPERTY(isSelected, BOOL)
9
11
 
10
12
  @end
11
-
@@ -23,7 +23,7 @@ extension RCTMGLShapeSourceManager {
23
23
  let view = viewRegistry![reactTag]
24
24
 
25
25
  guard let shapeSource = view! as? RCTMGLShapeSource else {
26
- RCTLogError("Invalid react tag, could not find RCTMGLShapeSource");
26
+ RCTMGLLogError("Invalid react tag, could not find RCTMGLShapeSource");
27
27
  rejecter(name, "Unknown find reactTag: \(reactTag)", nil)
28
28
  return;
29
29
  }
@@ -35,7 +35,7 @@ class RCTMGLUtils {
35
35
  RCTMGLImageQueue.sharedInstance.addImage(objects[imageName], scale: scale, bridge:bridge) {
36
36
  (error,image) in
37
37
  if image == nil {
38
- RCTLogWarn("Failed to fetch image: \(imageName) error:\(error)")
38
+ RCTMGLLogWarn("Failed to fetch image: \(imageName) error:\(error)")
39
39
  }
40
40
  else {
41
41
  DispatchQueue.main.async {
@@ -15,7 +15,7 @@ class RCTMGLVectorLayer: RCTMGLLayer {
15
15
  ((MGLVectorStyleLayer *) self.styleLayer).predicate = predicate;
16
16
  }
17
17
  @catch (NSException* exception) {
18
- RCTLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self, exception.name, exception.reason);
18
+ RCTMGLLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self, exception.name, exception.reason);
19
19
  }
20
20
  }
21
21
 
package/ios/install.md CHANGED
@@ -56,10 +56,11 @@ Add the following to the beginning of your podfile
56
56
  $RNMapboxMapsImpl = 'mapbox'
57
57
  ```
58
58
 
59
- You can also specify the version to use. *Warning:* if you set a version, then later update, the `rnamapbox/maps` library it's possible that you'll end up using Mapbox older version than supported. Make sure you revise this value with `rnmapbox/maps` updates.
59
+ You can also override the version to use. *Warning:* if you set a version, then later update, the `rnamapbox/maps` library it's possible that you'll end up using Mapbox older version than supported. Make sure you revise this value with `rnmapbox/maps` updates.
60
60
 
61
61
  ```ruby
62
- $RNMapboxMapsVersion = '~> 10.9.0'
62
+ # Warning: only for advanced use cases, only do this if you know what you're doing.
63
+ # $RNMapboxMapsVersion = '~> 10.9.0'
63
64
  ```
64
65
 
65
66
  You will need to authorize your download of the Maps SDK with a secret access token with the `DOWNLOADS:READ` scope. This [guide](https://docs.mapbox.com/ios/maps/guides/install/#configure-credentials) explains how to configure the secret token under section `Configure your secret token`.
@@ -4,7 +4,7 @@ import { NativeMethods, processColor } from 'react-native';
4
4
 
5
5
  import { getFilter } from '../utils/filterUtils';
6
6
  import { transformStyle } from '../utils/StyleValue';
7
- import { AllLayerStyleProps } from '../utils/MapboxStyles';
7
+ import { AllLayerStyleProps, Expression } from '../utils/MapboxStyles';
8
8
 
9
9
  type PropsBase = {
10
10
  id: string;
@@ -14,7 +14,7 @@ type PropsBase = {
14
14
  aboveLayerID?: string;
15
15
  belowLayerID?: string;
16
16
  layerIndex?: number;
17
- filter?: string[];
17
+ filter?: Expression;
18
18
  style: AllLayerStyleProps;
19
19
  };
20
20
 
@@ -42,11 +42,11 @@ class AbstractLayer<
42
42
  | (React.Component<NativePropsType> & Readonly<NativeMethods>)
43
43
  | undefined = undefined;
44
44
 
45
- setNativeLayer(
45
+ setNativeLayer = (
46
46
  instance: React.Component<NativePropsType> & Readonly<NativeMethods>,
47
- ) {
47
+ ) => {
48
48
  this.nativeLayer = instance;
49
- }
49
+ };
50
50
 
51
51
  getStyleTypeFormatter(styleType: string) {
52
52
  if (styleType === 'color') {
@@ -62,7 +62,10 @@ class AbstractLayer<
62
62
  if (this.nativeLayer) {
63
63
  let propsToPass = props;
64
64
  if (props.style) {
65
- propsToPass = { ...props, reactStyle: this.getStyle(props.style) };
65
+ propsToPass = {
66
+ ...props,
67
+ reactStyle: this.getStyle(props.style as AllLayerStyleProps),
68
+ };
66
69
  }
67
70
  this.nativeLayer?.setNativeProps(propsToPass);
68
71
  }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { NativeMethods } from 'react-native';
3
+
4
+ class AbstractSource<
5
+ PropsType,
6
+ NativePropsType extends object,
7
+ > extends React.PureComponent<PropsType> {
8
+ _nativeRef?: React.Component<NativePropsType> & Readonly<NativeMethods>;
9
+
10
+ setNativeProps(props: NativePropsType) {
11
+ if (this._nativeRef) {
12
+ this._nativeRef.setNativeProps(props);
13
+ }
14
+ }
15
+
16
+ setNativeRef: (
17
+ instance: React.Component<NativePropsType> & Readonly<NativeMethods>,
18
+ ) => void = (instance) => {
19
+ this._nativeRef = instance;
20
+ };
21
+ }
22
+
23
+ export default AbstractSource;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import headingIcon from '../../assets/heading.png';
4
4
 
5
- import SymbolLayer from './SymbolLayer';
5
+ import { SymbolLayer } from './SymbolLayer';
6
6
 
7
7
  const style = {
8
8
  iconImage: headingIcon,
@@ -4,7 +4,7 @@ import { requireNativeComponent, Image } from 'react-native';
4
4
 
5
5
  import { viewPropTypes } from '../utils';
6
6
 
7
- import ShapeSource from './ShapeSource';
7
+ import { ShapeSource } from './ShapeSource';
8
8
 
9
9
  export const NATIVE_MODULE_NAME = 'RCTMGLImages';
10
10
 
@@ -42,7 +42,10 @@ const defaultStyleURL = MapboxGL.StyleURL.Street;
42
42
  /**
43
43
  * MapView backed by Mapbox Native GL
44
44
  */
45
- class MapView extends NativeBridgeComponent(React.Component) {
45
+ class MapView extends NativeBridgeComponent(
46
+ React.Component,
47
+ NATIVE_MODULE_NAME,
48
+ ) {
46
49
  static propTypes = {
47
50
  ...viewPropTypes,
48
51
 
@@ -306,7 +309,7 @@ class MapView extends NativeBridgeComponent(React.Component) {
306
309
  };
307
310
 
308
311
  constructor(props) {
309
- super(props, NATIVE_MODULE_NAME);
312
+ super(props);
310
313
 
311
314
  this.logger = Logger.sharedInstance();
312
315
  this.logger.start();