@rnmapbox/maps 10.0.0-beta.53 → 10.0.0-beta.56
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/annotation/RCTMGLMarkerViewManager.kt +28 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +3 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +2 -1
- package/app.plugin.js +1 -0
- package/index.d.ts +27 -4
- package/ios/RCTMGL-v10/MGLModule.m +3 -1
- package/ios/RCTMGL-v10/MGLModule.swift +9 -1
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +2 -2
- package/ios/RCTMGL-v10/RCTMGLCircleLayer.swift +1 -20
- package/ios/RCTMGL-v10/RCTMGLImages.swift +1 -1
- package/ios/RCTMGL-v10/RCTMGLInteractiveElement.swift +4 -12
- package/ios/RCTMGL-v10/RCTMGLLayer.swift +2 -1
- package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +19 -5
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +24 -8
- package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +5 -5
- package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +1 -1
- package/ios/RCTMGL-v10/RCTMGLPointAnnotation.swift +1 -1
- package/ios/RCTMGL-v10/RCTMGLSingletonLayer.swift +2 -2
- package/ios/RCTMGL-v10/RCTMGLSource.swift +23 -1
- package/ios/RCTMGL-v10/RCTMGLStyleValue.swift +1 -1
- package/ios/RCTMGL-v10/RCTMGLVectorLayer.swift +0 -44
- package/javascript/components/AbstractLayer.tsx +4 -4
- package/javascript/components/LineLayer.tsx +91 -0
- package/javascript/components/SymbolLayer.tsx +1 -1
- package/javascript/utils/MapboxStyles.d.ts +2 -0
- package/javascript/utils/StyleValue.ts +1 -1
- package/lib/commonjs/components/AbstractLayer.js.map +1 -1
- package/lib/commonjs/components/LineLayer.js +2 -55
- package/lib/commonjs/components/LineLayer.js.map +1 -1
- package/lib/commonjs/utils/MapboxStyles.d.js.map +1 -1
- package/lib/commonjs/utils/StyleValue.js.map +1 -1
- package/lib/commonjs/web/utils/Logger.js.map +1 -1
- package/lib/module/components/AbstractLayer.js.map +1 -1
- package/lib/module/components/LineLayer.js +1 -54
- package/lib/module/components/LineLayer.js.map +1 -1
- package/lib/module/utils/MapboxStyles.d.js.map +1 -1
- package/lib/module/utils/StyleValue.js.map +1 -1
- package/lib/module/web/utils/Logger.js.map +1 -1
- package/lib/typescript/components/AbstractLayer.d.ts +4 -4
- package/lib/typescript/components/AbstractLayer.d.ts.map +1 -1
- package/lib/typescript/components/LineLayer.d.ts +65 -0
- package/lib/typescript/components/LineLayer.d.ts.map +1 -0
- package/lib/typescript/components/SymbolLayer.d.ts +1 -1
- package/lib/typescript/components/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/utils/StyleValue.d.ts +1 -1
- package/lib/typescript/utils/StyleValue.d.ts.map +1 -1
- package/package.json +3 -2
- package/plugin/build/withMapbox.js +29 -21
- package/plugin/src/withMapbox.ts +31 -22
- package/javascript/components/LineLayer.js +0 -94
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.mapbox.rctmgl.components.annotation
|
|
2
2
|
|
|
3
3
|
import android.view.View
|
|
4
|
+
import android.widget.FrameLayout
|
|
4
5
|
import com.mapbox.rctmgl.utils.GeoJSONUtils.toPointGeometry
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
7
|
import com.mapbox.rctmgl.components.AbstractEventEmitter
|
|
@@ -8,6 +9,10 @@ import com.facebook.react.uimanager.annotations.ReactProp
|
|
|
8
9
|
import com.facebook.react.bridge.ReadableMap
|
|
9
10
|
import com.facebook.react.common.MapBuilder
|
|
10
11
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
12
|
+
import com.mapbox.maps.ScreenCoordinate
|
|
13
|
+
import com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener
|
|
14
|
+
import com.mapbox.maps.viewannotation.ViewAnnotationManager
|
|
15
|
+
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView
|
|
11
16
|
|
|
12
17
|
class RCTMGLMarkerViewManager(reactApplicationContext: ReactApplicationContext?) :
|
|
13
18
|
AbstractEventEmitter<RCTMGLMarkerView?>(reactApplicationContext) {
|
|
@@ -46,5 +51,28 @@ class RCTMGLMarkerViewManager(reactApplicationContext: ReactApplicationContext?)
|
|
|
46
51
|
|
|
47
52
|
companion object {
|
|
48
53
|
const val REACT_CLASS = "RCTMGLMarkerView"
|
|
54
|
+
|
|
55
|
+
fun markerViewContainerSizeFixer(mapView: RCTMGLMapView, viewAnnotationManager: ViewAnnotationManager) {
|
|
56
|
+
// see https://github.com/rnmapbox/maps/issues/2376
|
|
57
|
+
viewAnnotationManager.addOnViewAnnotationUpdatedListener(object :
|
|
58
|
+
OnViewAnnotationUpdatedListener {
|
|
59
|
+
override fun onViewAnnotationVisibilityUpdated(view: View, visible: Boolean) {
|
|
60
|
+
val parent = view.parent
|
|
61
|
+
if (parent is FrameLayout) {
|
|
62
|
+
if ((parent.width == 0 && parent.height == 0) && (mapView.width != 0 || mapView.height != 0)) {
|
|
63
|
+
parent.layout(0,0,mapView.width, mapView.height)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override fun onViewAnnotationPositionUpdated(
|
|
69
|
+
view: View,
|
|
70
|
+
leftTopCoordinate: ScreenCoordinate,
|
|
71
|
+
width: Int,
|
|
72
|
+
height: Int
|
|
73
|
+
) {
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
49
77
|
}
|
|
50
78
|
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -43,6 +43,7 @@ import com.mapbox.maps.plugin.scalebar.scalebar
|
|
|
43
43
|
import com.mapbox.rctmgl.R
|
|
44
44
|
import com.mapbox.rctmgl.components.AbstractMapFeature
|
|
45
45
|
import com.mapbox.rctmgl.components.annotation.RCTMGLMarkerView
|
|
46
|
+
import com.mapbox.rctmgl.components.annotation.RCTMGLMarkerViewManager
|
|
46
47
|
import com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation
|
|
47
48
|
import com.mapbox.rctmgl.components.camera.RCTMGLCamera
|
|
48
49
|
import com.mapbox.rctmgl.components.images.RCTMGLImages
|
|
@@ -900,6 +901,8 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
900
901
|
images.sendImageMissingEvent(id, mMap)
|
|
901
902
|
}
|
|
902
903
|
})
|
|
904
|
+
|
|
905
|
+
RCTMGLMarkerViewManager.markerViewContainerSizeFixer(this, viewAnnotationManager)
|
|
903
906
|
}
|
|
904
907
|
|
|
905
908
|
// region Ornaments
|
|
@@ -269,11 +269,12 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext?) :
|
|
|
269
269
|
);
|
|
270
270
|
}
|
|
271
271
|
METHOD_QUERY_FEATURES_RECT -> {
|
|
272
|
+
val layerIds = ConvertUtils.toStringList(args!!.getArray(3))
|
|
272
273
|
mapView.queryRenderedFeaturesInRect(
|
|
273
274
|
args!!.getString(0),
|
|
274
275
|
ConvertUtils.toRectF(args.getArray(1)),
|
|
275
276
|
ExpressionParser.from(args!!.getArray(2)),
|
|
276
|
-
|
|
277
|
+
if (layerIds.size == 0) null else layerIds
|
|
277
278
|
);
|
|
278
279
|
}
|
|
279
280
|
METHOD_VISIBLE_BOUNDS -> {
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withMapbox');
|
package/index.d.ts
CHANGED
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
FeatureCollection,
|
|
23
23
|
} from '@turf/helpers';
|
|
24
24
|
|
|
25
|
-
import type {
|
|
25
|
+
import type {
|
|
26
|
+
SymbolLayerStyleProps,
|
|
27
|
+
LineLayerStyleProps,
|
|
28
|
+
} from './javascript/utils/MapboxStyles';
|
|
26
29
|
import {
|
|
27
30
|
Camera as _Camera,
|
|
28
31
|
CameraStop as _CameraStop,
|
|
@@ -43,6 +46,10 @@ import {
|
|
|
43
46
|
SymbolLayer as _SymbolLayer,
|
|
44
47
|
Props as _SymbolLayerProps,
|
|
45
48
|
} from './javascript/components/SymbolLayer';
|
|
49
|
+
import {
|
|
50
|
+
LineLayer as _LineLayer,
|
|
51
|
+
Props as _LineLayerProps,
|
|
52
|
+
} from './javascript/components/LineLayer';
|
|
46
53
|
import {
|
|
47
54
|
ShapeSource as _ShapeSource,
|
|
48
55
|
Props as _ShapeSourceProps,
|
|
@@ -107,7 +114,7 @@ type NamedStyles<T> = {
|
|
|
107
114
|
[P in keyof T]:
|
|
108
115
|
| SymbolLayerStyleProps
|
|
109
116
|
| RasterLayerStyle
|
|
110
|
-
|
|
|
117
|
+
| LineLayerStyleProps
|
|
111
118
|
| FillLayerStyle
|
|
112
119
|
| FillExtrusionLayerStyle
|
|
113
120
|
| CircleLayerStyle
|
|
@@ -152,6 +159,7 @@ declare namespace MapboxGL {
|
|
|
152
159
|
const MarkerView = _MarkerView;
|
|
153
160
|
const PointAnnotation = _PointAnnotation;
|
|
154
161
|
const SymbolLayer = _SymbolLayer;
|
|
162
|
+
const LineLayer = _LineLayer;
|
|
155
163
|
const ShapeSource = _ShapeSource;
|
|
156
164
|
type ShapeSource = _ShapeSource;
|
|
157
165
|
|
|
@@ -187,6 +195,21 @@ declare namespace MapboxGL {
|
|
|
187
195
|
constructor(shape: _AnimatedShape);
|
|
188
196
|
}
|
|
189
197
|
|
|
198
|
+
class _TileServers {
|
|
199
|
+
Mapbox: string;
|
|
200
|
+
MapLibre?: string;
|
|
201
|
+
MapTiler?: string;
|
|
202
|
+
}
|
|
203
|
+
const TileServers: _TileServers;
|
|
204
|
+
|
|
205
|
+
class _OfflinePackDownloadState {
|
|
206
|
+
Inactive: string | number;
|
|
207
|
+
Active: string | number;
|
|
208
|
+
Complete: string | number;
|
|
209
|
+
Unknown?: string | number;
|
|
210
|
+
}
|
|
211
|
+
const OfflinePackDownloadState: _OfflinePackDownloadState;
|
|
212
|
+
|
|
190
213
|
/**
|
|
191
214
|
* GeoUtils
|
|
192
215
|
*/
|
|
@@ -256,7 +279,7 @@ declare namespace MapboxGL {
|
|
|
256
279
|
// layers
|
|
257
280
|
class FillLayer extends Component<FillLayerProps> {}
|
|
258
281
|
class FillExtrusionLayer extends Component<FillExtrusionLayerProps> {}
|
|
259
|
-
class LineLayer extends Component<
|
|
282
|
+
class LineLayer extends Component<_LineLayerProps> {}
|
|
260
283
|
class CircleLayer extends Component<CircleLayerProps> {}
|
|
261
284
|
class SymbolLayer extends Component<_SymbolLayerProps> {}
|
|
262
285
|
class RasterLayer extends Component<RasterLayerProps> {}
|
|
@@ -737,8 +760,8 @@ export type TextVariableAnchorValues =
|
|
|
737
760
|
| 'bottom-left'
|
|
738
761
|
| 'bottom-right';
|
|
739
762
|
|
|
740
|
-
/** @deprecated Will be removed in next betas */
|
|
741
763
|
export type SymbolLayerStyle = SymbolLayerStyleProps;
|
|
764
|
+
export type LineLayerStyle = LineLayerStyleProps;
|
|
742
765
|
|
|
743
766
|
export interface HeatmapLayerStyle {
|
|
744
767
|
visibility?: Visibility | Expression;
|
|
@@ -7,6 +7,8 @@ RCT_EXTERN_METHOD(setAccessToken:(NSString *)accessToken resolver:(RCTPromiseRes
|
|
|
7
7
|
RCT_EXTERN_METHOD(addCustomHeader:(NSString *)headerName forHeaderValue:(NSString *) headerValue)
|
|
8
8
|
RCT_EXTERN_METHOD(removeCustomHeader:(NSString *)headerName)
|
|
9
9
|
|
|
10
|
-
RCT_EXTERN_METHOD(setTelemetryEnabled:(BOOL)telemetryEnabled
|
|
10
|
+
RCT_EXTERN_METHOD(setTelemetryEnabled:(BOOL)telemetryEnabled)
|
|
11
|
+
RCT_EXTERN_METHOD(setWellKnownTileServer:(NSString *)tileServer)
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
@end
|
|
@@ -61,7 +61,9 @@ class MGLModule : NSObject {
|
|
|
61
61
|
[
|
|
62
62
|
"Error": RCTMGLOfflineModule.Callbacks.error.rawValue,
|
|
63
63
|
"Progress": RCTMGLOfflineModule.Callbacks.progress.rawValue
|
|
64
|
-
]
|
|
64
|
+
],
|
|
65
|
+
"TileServers":
|
|
66
|
+
["Mapbox": "mapbox"]
|
|
65
67
|
];
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -89,4 +91,10 @@ class MGLModule : NSObject {
|
|
|
89
91
|
@objc func setTelemetryEnabled(_ telemetryEnabled: Bool) {
|
|
90
92
|
UserDefaults.mme_configuration().mme_isCollectionEnabled = telemetryEnabled
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
@objc func setWellKnownTileServer(_ tileServer: String) {
|
|
96
|
+
if tileServer != "mapbox" {
|
|
97
|
+
Logger.error("setWellKnownTileServer: \(tileServer) should be mapbox")
|
|
98
|
+
}
|
|
99
|
+
}
|
|
92
100
|
}
|
|
@@ -65,10 +65,10 @@ class CameraUpdateQueue {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
open class RCTMGLMapComponentBase : UIView, RCTMGLMapComponent {
|
|
68
|
-
private var _map: RCTMGLMapView! = nil
|
|
68
|
+
private weak var _map: RCTMGLMapView! = nil
|
|
69
69
|
private var _mapCallbacks: [(RCTMGLMapView) -> Void] = []
|
|
70
70
|
|
|
71
|
-
var map : RCTMGLMapView? {
|
|
71
|
+
weak var map : RCTMGLMapView? {
|
|
72
72
|
return _map;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -6,7 +6,7 @@ class RCTMGLCircleLayer: RCTMGLVectorLayer {
|
|
|
6
6
|
typealias LayerType = CircleLayer
|
|
7
7
|
|
|
8
8
|
override func makeLayer(style: Style) throws -> Layer {
|
|
9
|
-
let
|
|
9
|
+
let _ : VectorSource = try self.layerWithSourceID(in: style)
|
|
10
10
|
var layer = LayerType(id: self.id!)
|
|
11
11
|
layer.sourceLayer = self.sourceLayerID
|
|
12
12
|
layer.source = sourceID
|
|
@@ -44,23 +44,4 @@ class RCTMGLCircleLayer: RCTMGLVectorLayer {
|
|
|
44
44
|
func isAddedToMap() -> Bool {
|
|
45
45
|
return true
|
|
46
46
|
}
|
|
47
|
-
/*
|
|
48
|
-
- (MGLCircleStyleLayer*)makeLayer:(MGLStyle*)style
|
|
49
|
-
{
|
|
50
|
-
MGLSource *source = [self layerWithSourceIDInStyle:style];
|
|
51
|
-
if (source == nil) { return nil; }
|
|
52
|
-
MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:self.id source:source];
|
|
53
|
-
layer.sourceLayerIdentifier = self.sourceLayerID;
|
|
54
|
-
return layer;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
- (void)addStyles
|
|
58
|
-
{
|
|
59
|
-
RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
|
|
60
|
-
style.bridge = self.bridge;
|
|
61
|
-
[style circleLayer:(MGLCircleStyleLayer*)self.styleLayer withReactStyle:self.reactStyle isValid:^{
|
|
62
|
-
return [self isAddedToMap];
|
|
63
|
-
}];
|
|
64
|
-
}*/
|
|
65
|
-
|
|
66
47
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import MapboxMaps
|
|
2
2
|
|
|
3
3
|
@objc
|
|
4
4
|
class RCTMGLInteractiveElement : UIView, RCTMGLMapComponent {
|
|
5
5
|
|
|
6
|
-
var map : RCTMGLMapView? = nil
|
|
7
|
-
|
|
8
|
-
var layers: [RCTMGLSourceConsumer] = []
|
|
9
|
-
|
|
6
|
+
weak var map : RCTMGLMapView? = nil
|
|
7
|
+
|
|
10
8
|
static let hitboxDefault = 44.0
|
|
11
9
|
|
|
12
10
|
@objc var draggable: Bool = false
|
|
@@ -25,13 +23,7 @@ class RCTMGLInteractiveElement : UIView, RCTMGLMapComponent {
|
|
|
25
23
|
@objc var onPress: RCTBubblingEventBlock? = nil
|
|
26
24
|
|
|
27
25
|
func getLayerIDs() -> [String] {
|
|
28
|
-
|
|
29
|
-
if let layer = $0 as? RCTMGLLayer {
|
|
30
|
-
return layer.id
|
|
31
|
-
} else {
|
|
32
|
-
return nil
|
|
33
|
-
}
|
|
34
|
-
}
|
|
26
|
+
return []
|
|
35
27
|
}
|
|
36
28
|
|
|
37
29
|
func isDraggable() -> Bool {
|
|
@@ -7,11 +7,12 @@ protocol RCTMGLSourceConsumer {
|
|
|
7
7
|
|
|
8
8
|
@objc(RCTMGLLayer)
|
|
9
9
|
class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
|
|
10
|
-
var bridge : RCTBridge? = nil
|
|
10
|
+
weak var bridge : RCTBridge? = nil
|
|
11
11
|
|
|
12
12
|
@objc var sourceLayerID : String? = nil {
|
|
13
13
|
didSet { self.optionsChanged() }
|
|
14
14
|
}
|
|
15
|
+
|
|
15
16
|
@objc var reactStyle : Dictionary<String, Any>? = nil {
|
|
16
17
|
didSet {
|
|
17
18
|
DispatchQueue.main.async {
|
|
@@ -27,8 +27,16 @@ typealias RCTMGLLocationBlock = (RCTMGLLocation?) -> Void
|
|
|
27
27
|
|
|
28
28
|
let RCT_MAPBOX_USER_LOCATION_UPDATE = "MapboxUserLocationUpdate";
|
|
29
29
|
|
|
30
|
+
/// This implementation of LocationProviderDelegate is used by `LocationManager` to work around
|
|
31
|
+
/// the fact that the `LocationProvider` API does not allow the delegate to be set to `nil`.
|
|
32
|
+
internal class EmptyLocationProviderDelegate: LocationProviderDelegate {
|
|
33
|
+
func locationProvider(_ provider: LocationProvider, didFailWithError error: Error) {}
|
|
34
|
+
func locationProvider(_ provider: LocationProvider, didUpdateHeading newHeading: CLHeading) {}
|
|
35
|
+
func locationProvider(_ provider: LocationProvider, didUpdateLocations locations: [CLLocation]) {}
|
|
36
|
+
func locationProviderDidChangeAuthorization(_ provider: LocationProvider) {}
|
|
37
|
+
}
|
|
30
38
|
|
|
31
|
-
protocol RCTMGLLocationManagerDelegate {
|
|
39
|
+
protocol RCTMGLLocationManagerDelegate : AnyObject {
|
|
32
40
|
func locationManager(_ locationManager: RCTMGLLocationManager, didUpdateLocation: RCTMGLLocation)
|
|
33
41
|
}
|
|
34
42
|
|
|
@@ -38,8 +46,8 @@ class RCTMGLLocationManager : LocationProviderDelegate {
|
|
|
38
46
|
var lastKnownLocation : CLLocation?
|
|
39
47
|
var lastKnownHeading : CLHeading?
|
|
40
48
|
|
|
41
|
-
var delegate: RCTMGLLocationManagerDelegate?
|
|
42
|
-
var locationProviderDelage: LocationProviderDelegate?
|
|
49
|
+
weak var delegate: RCTMGLLocationManagerDelegate?
|
|
50
|
+
weak var locationProviderDelage: LocationProviderDelegate?
|
|
43
51
|
|
|
44
52
|
var listeners: [RCTMGLLocationBlock] = []
|
|
45
53
|
|
|
@@ -60,6 +68,12 @@ class RCTMGLLocationManager : LocationProviderDelegate {
|
|
|
60
68
|
provider.startUpdatingLocation()
|
|
61
69
|
}
|
|
62
70
|
|
|
71
|
+
func stop() {
|
|
72
|
+
provider.stopUpdatingHeading()
|
|
73
|
+
provider.stopUpdatingLocation()
|
|
74
|
+
provider.setDelegate(EmptyLocationProviderDelegate())
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
func _convertToMapboxLocation(_ location: CLLocation?) -> RCTMGLLocation {
|
|
64
78
|
guard let location = location else {
|
|
65
79
|
return RCTMGLLocation()
|
|
@@ -192,7 +206,7 @@ extension RCTMGLLocationManager: LocationProvider {
|
|
|
192
206
|
@objc(RCTMGLLocationModule)
|
|
193
207
|
class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
194
208
|
|
|
195
|
-
static var shared : RCTMGLLocationModule? = nil
|
|
209
|
+
static weak var shared : RCTMGLLocationModule? = nil
|
|
196
210
|
|
|
197
211
|
var locationManager : RCTMGLLocationManager
|
|
198
212
|
var hasListener = false
|
|
@@ -233,7 +247,7 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
@objc func stop() {
|
|
236
|
-
|
|
250
|
+
locationManager.stop()
|
|
237
251
|
}
|
|
238
252
|
|
|
239
253
|
@objc func getLastKnownLocation() -> RCTMGLLocation? {
|
|
@@ -15,7 +15,7 @@ open class RCTMGLMapView : MapView {
|
|
|
15
15
|
var styleLoaded: Bool = false
|
|
16
16
|
var styleLoadWaiters : [(MapboxMap)->Void] = []
|
|
17
17
|
|
|
18
|
-
var reactCamera : RCTMGLCamera?
|
|
18
|
+
weak var reactCamera : RCTMGLCamera?
|
|
19
19
|
var images : [RCTMGLImages] = []
|
|
20
20
|
var sources : [RCTMGLInteractiveElement] = []
|
|
21
21
|
|
|
@@ -282,10 +282,26 @@ open class RCTMGLMapView : MapView {
|
|
|
282
282
|
// MARK: - event handlers
|
|
283
283
|
|
|
284
284
|
extension RCTMGLMapView {
|
|
285
|
+
private func onEvery<Payload>(event: MapEvents.Event<Payload>, handler: @escaping (RCTMGLMapView, MapEvent<Payload>) -> Void) {
|
|
286
|
+
self.mapView.mapboxMap.onEvery(event: event) { [weak self](mapEvent) in
|
|
287
|
+
guard let self = self else { return }
|
|
288
|
+
|
|
289
|
+
handler(self, mapEvent)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private func onNext<Payload>(event: MapEvents.Event<Payload>, handler: @escaping (RCTMGLMapView, MapEvent<Payload>) -> Void) {
|
|
294
|
+
self.mapView.mapboxMap.onNext(event: event) { [weak self](mapEvent) in
|
|
295
|
+
guard let self = self else { return }
|
|
296
|
+
|
|
297
|
+
handler(self, mapEvent)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
285
301
|
@objc func setReactOnMapChange(_ value: @escaping RCTBubblingEventBlock) {
|
|
286
302
|
self.reactOnMapChange = value
|
|
287
303
|
|
|
288
|
-
self.
|
|
304
|
+
self.onEvery(event: .cameraChanged, handler: { (self, cameraEvent) in
|
|
289
305
|
self.wasGestureActive = self.isGestureActive
|
|
290
306
|
if self.handleMapChangedEvents.contains(.regionIsChanging) {
|
|
291
307
|
let event = RCTMGLEvent(type:.regionIsChanging, payload: self.buildRegionObject());
|
|
@@ -296,7 +312,7 @@ extension RCTMGLMapView {
|
|
|
296
312
|
}
|
|
297
313
|
})
|
|
298
314
|
|
|
299
|
-
self.
|
|
315
|
+
self.onEvery(event: .mapIdle, handler: { (self, cameraEvent) in
|
|
300
316
|
if self.handleMapChangedEvents.contains(.regionDidChange) {
|
|
301
317
|
let event = RCTMGLEvent(type:.regionDidChange, payload: self.buildRegionObject());
|
|
302
318
|
self.fireEvent(event: event, callback: self.reactOnMapChange)
|
|
@@ -367,7 +383,7 @@ extension RCTMGLMapView {
|
|
|
367
383
|
}
|
|
368
384
|
|
|
369
385
|
public func setupEvents() {
|
|
370
|
-
self.
|
|
386
|
+
self.onEvery(event: .mapLoadingError, handler: {(self, event) in
|
|
371
387
|
if let message = event.payload.error.errorDescription {
|
|
372
388
|
Logger.log(level: .error, message: "MapLoad error \(message)")
|
|
373
389
|
} else {
|
|
@@ -375,7 +391,7 @@ extension RCTMGLMapView {
|
|
|
375
391
|
}
|
|
376
392
|
})
|
|
377
393
|
|
|
378
|
-
self.
|
|
394
|
+
self.onEvery(event: .styleImageMissing) { (self, event) in
|
|
379
395
|
let imageName = event.payload.id
|
|
380
396
|
|
|
381
397
|
self.images.forEach {
|
|
@@ -389,7 +405,7 @@ extension RCTMGLMapView {
|
|
|
389
405
|
}
|
|
390
406
|
}
|
|
391
407
|
|
|
392
|
-
self.
|
|
408
|
+
self.onEvery(event: .renderFrameFinished, handler: { (self, event) in
|
|
393
409
|
var type = RCTMGLEvent.EventType.didFinishRendering
|
|
394
410
|
if event.payload.renderMode == .full {
|
|
395
411
|
type = .didFinishRenderingFully
|
|
@@ -403,12 +419,12 @@ extension RCTMGLMapView {
|
|
|
403
419
|
self.fireEvent(event: event, callback: self.reactOnMapChange)
|
|
404
420
|
})
|
|
405
421
|
|
|
406
|
-
self.
|
|
422
|
+
self.onNext(event: .mapLoaded, handler: { (self, event) in
|
|
407
423
|
let event = RCTMGLEvent(type:.didFinishLoadingMap, payload: nil);
|
|
408
424
|
self.fireEvent(event: event, callback: self.reactOnMapChange)
|
|
409
425
|
})
|
|
410
426
|
|
|
411
|
-
self.
|
|
427
|
+
self.onEvery(event: .styleLoaded, handler: { (self, event) in
|
|
412
428
|
self.onStyleLoadedComponents.forEach { (component) in
|
|
413
429
|
component.addToMap(self, style: self.mapboxMap.style)
|
|
414
430
|
}
|
|
@@ -215,13 +215,13 @@ extension RCTMGLMapViewManager {
|
|
|
215
215
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
216
216
|
rejecter: @escaping RCTPromiseRejectBlock) -> Void {
|
|
217
217
|
withMapView(reactTag, name:"queryRenderedFeaturesInRect", rejecter: rejecter) { mapView in
|
|
218
|
-
let
|
|
219
|
-
let
|
|
220
|
-
let
|
|
221
|
-
let
|
|
218
|
+
let top = bbox.isEmpty ? 0.0 : CGFloat(bbox[0].floatValue)
|
|
219
|
+
let right = bbox.isEmpty ? 0.0 : CGFloat(bbox[1].floatValue)
|
|
220
|
+
let bottom = bbox.isEmpty ? 0.0 : CGFloat(bbox[2].floatValue)
|
|
221
|
+
let left = bbox.isEmpty ? 0.0 : CGFloat(bbox[3].floatValue)
|
|
222
222
|
let rect = bbox.isEmpty ? CGRect(x: 0.0, y: 0.0, width: mapView.bounds.size.width, height: mapView.bounds.size.height) : CGRect(x: [left,right].min()!, y: [top,bottom].min()!, width: abs(right-left), height: abs(bottom-top))
|
|
223
223
|
logged("queryRenderedFeaturesInRect.option", rejecter: rejecter) {
|
|
224
|
-
let options = try RenderedQueryOptions(layerIds: layerIDs, filter: filter?.asExpression())
|
|
224
|
+
let options = try RenderedQueryOptions(layerIds: layerIDs?.isEmpty ?? true ? nil : layerIDs, filter: filter?.asExpression())
|
|
225
225
|
mapView.mapboxMap.queryRenderedFeatures(with: rect, options: options) { result in
|
|
226
226
|
switch result {
|
|
227
227
|
case .success(let features):
|
|
@@ -14,7 +14,7 @@ class RCTMGLPointAnnotation : RCTMGLInteractiveElement {
|
|
|
14
14
|
static var gid = 0;
|
|
15
15
|
|
|
16
16
|
var annotation : PointAnnotation! = nil
|
|
17
|
-
var callout: RCTMGLCallout? = nil
|
|
17
|
+
weak var callout: RCTMGLCallout? = nil
|
|
18
18
|
var calloutId : String?
|
|
19
19
|
var image : UIImage? = nil
|
|
20
20
|
var reactSubviews : [UIView] = []
|
|
@@ -3,8 +3,8 @@ import MapboxMaps
|
|
|
3
3
|
/// RCTMGLSingletonLayer is absract superclass for Light, Atmosphere, Terrain
|
|
4
4
|
@objc
|
|
5
5
|
class RCTMGLSingletonLayer : UIView {
|
|
6
|
-
var bridge : RCTBridge? = nil
|
|
7
|
-
var map : RCTMGLMapView? = nil
|
|
6
|
+
weak var bridge : RCTBridge? = nil
|
|
7
|
+
weak var map : RCTMGLMapView? = nil
|
|
8
8
|
var style: Style? = nil
|
|
9
9
|
|
|
10
10
|
@objc var reactStyle : Dictionary<String, Any>? = nil {
|
|
@@ -2,11 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
@objc
|
|
4
4
|
class RCTMGLSource : RCTMGLInteractiveElement {
|
|
5
|
-
|
|
5
|
+
var layers: [RCTMGLSourceConsumer] = []
|
|
6
|
+
|
|
6
7
|
var source : Source? = nil
|
|
7
8
|
|
|
8
9
|
var ownsSource : Bool = false
|
|
9
10
|
|
|
11
|
+
override func getLayerIDs() -> [String] {
|
|
12
|
+
layers.compactMap {
|
|
13
|
+
if let layer = $0 as? RCTMGLLayer {
|
|
14
|
+
return layer.id
|
|
15
|
+
} else {
|
|
16
|
+
return nil
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
func makeSource() -> Source {
|
|
11
22
|
fatalError("Subclasses should override makeSource")
|
|
12
23
|
}
|
|
@@ -15,6 +26,8 @@ class RCTMGLSource : RCTMGLInteractiveElement {
|
|
|
15
26
|
fatalError("Subclasses should override makeSource")
|
|
16
27
|
}
|
|
17
28
|
|
|
29
|
+
// MARK: - UIView+React
|
|
30
|
+
|
|
18
31
|
@objc override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
|
|
19
32
|
if let layer : RCTMGLSourceConsumer = subview as? RCTMGLSourceConsumer {
|
|
20
33
|
if let map = map {
|
|
@@ -22,6 +35,15 @@ class RCTMGLSource : RCTMGLInteractiveElement {
|
|
|
22
35
|
}
|
|
23
36
|
layers.append(layer)
|
|
24
37
|
}
|
|
38
|
+
super.insertReactSubview(subview, at: atIndex)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@objc override func removeReactSubview(_ subview: UIView!) {
|
|
42
|
+
super.removeReactSubview(subview)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@objc override func didUpdateReactSubviews() {
|
|
46
|
+
// do nothing to prevent inserting layers to UIView hierarchy
|
|
25
47
|
}
|
|
26
48
|
|
|
27
49
|
// MARK: - RCTMGLInteractiveElement
|
|
@@ -225,7 +225,7 @@ class RCTMGLStyleValue {
|
|
|
225
225
|
red: CGFloat((Float((rgbValue & 0xff0000) >> 16)) / 255.0),
|
|
226
226
|
green: CGFloat((Float((rgbValue & 0x00ff00) >> 8)) / 255.0),
|
|
227
227
|
blue: CGFloat((Float((rgbValue & 0x0000ff) >> 0)) / 255.0),
|
|
228
|
-
alpha:
|
|
228
|
+
alpha: CGFloat((rgbValue & 0xFF000000) >> 24) / 0xFF)
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
func mglStyleValueColor() -> Value<StyleColor> {
|
|
@@ -2,48 +2,4 @@ import MapboxMaps
|
|
|
2
2
|
|
|
3
3
|
@objc(RCTMGLVectorLayer)
|
|
4
4
|
class RCTMGLVectorLayer: RCTMGLLayer {
|
|
5
|
-
//@property (nonatomic, copy) NSString *sourceLayerID;
|
|
6
|
-
/*
|
|
7
|
-
- (NSPredicate*)buildFilters
|
|
8
|
-
{
|
|
9
|
-
return self.filter ? [FilterParser parse:self.filter] : nil;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
- (void)updateFilter:(NSPredicate *)predicate
|
|
13
|
-
{
|
|
14
|
-
@try {
|
|
15
|
-
((MGLVectorStyleLayer *) self.styleLayer).predicate = predicate;
|
|
16
|
-
}
|
|
17
|
-
@catch (NSException* exception) {
|
|
18
|
-
RCTMGLLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self, exception.name, exception.reason);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
- (void)setSourceLayerID:(NSString *)sourceLayerID
|
|
23
|
-
{
|
|
24
|
-
_sourceLayerID = sourceLayerID;
|
|
25
|
-
|
|
26
|
-
if (self.styleLayer != nil) {
|
|
27
|
-
((MGLVectorStyleLayer*) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
- (void)addedToMap
|
|
32
|
-
{
|
|
33
|
-
NSPredicate *filter = [self buildFilters];
|
|
34
|
-
if (filter != nil) {
|
|
35
|
-
[self updateFilter:filter];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
- (void)setFilter:(NSArray*)filter
|
|
40
|
-
{
|
|
41
|
-
[super setFilter: filter];
|
|
42
|
-
|
|
43
|
-
if (self.styleLayer != nil) {
|
|
44
|
-
NSPredicate *predicate = [self buildFilters];
|
|
45
|
-
[self updateFilter:predicate];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
*/
|
|
49
5
|
}
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { NativeMethods, processColor } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { getFilter } from '../utils/filterUtils';
|
|
6
|
-
import { AllLayerStyleProps,
|
|
6
|
+
import { AllLayerStyleProps, FilterExpression } from '../utils/MapboxStyles';
|
|
7
7
|
import { transformStyle } from '../utils/StyleValue';
|
|
8
8
|
|
|
9
9
|
type PropsBase = {
|
|
@@ -14,8 +14,8 @@ type PropsBase = {
|
|
|
14
14
|
aboveLayerID?: string;
|
|
15
15
|
belowLayerID?: string;
|
|
16
16
|
layerIndex?: number;
|
|
17
|
-
filter?:
|
|
18
|
-
style
|
|
17
|
+
filter?: FilterExpression;
|
|
18
|
+
style?: AllLayerStyleProps;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
class AbstractLayer<
|
|
@@ -55,7 +55,7 @@ class AbstractLayer<
|
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
getStyle(style: AllLayerStyleProps) {
|
|
58
|
+
getStyle(style: AllLayerStyleProps | undefined) {
|
|
59
59
|
return transformStyle(style);
|
|
60
60
|
}
|
|
61
61
|
|