@maplibre/maplibre-react-native 10.1.0 → 10.1.2
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/ios/MLRN/CameraStop.h +1 -1
- package/ios/MLRN/CameraStop.m +58 -60
- package/ios/MLRN/CameraUpdateItem.h +2 -1
- package/ios/MLRN/CameraUpdateItem.m +132 -132
- package/ios/MLRN/CameraUpdateQueue.m +43 -47
- package/ios/MLRN/FilterParser.h +1 -1
- package/ios/MLRN/FilterParser.m +5 -6
- package/ios/MLRN/MLRNBackgroundLayer.m +10 -9
- package/ios/MLRN/MLRNBackgroundLayerManager.m +4 -5
- package/ios/MLRN/MLRNCallout.h +1 -1
- package/ios/MLRN/MLRNCallout.m +37 -36
- package/ios/MLRN/MLRNCalloutManager.m +2 -3
- package/ios/MLRN/MLRNCamera.h +1 -1
- package/ios/MLRN/MLRNCamera.m +169 -182
- package/ios/MLRN/MLRNCameraManager.m +4 -6
- package/ios/MLRN/MLRNCircleLayer.m +17 -14
- package/ios/MLRN/MLRNCircleLayerManager.m +4 -5
- package/ios/MLRN/MLRNCustomHeaders.h +2 -2
- package/ios/MLRN/MLRNCustomHeaders.m +63 -63
- package/ios/MLRN/MLRNEvent.h +3 -3
- package/ios/MLRN/MLRNEvent.m +19 -24
- package/ios/MLRN/MLRNEventProtocol.h +1 -1
- package/ios/MLRN/MLRNFillExtrusionLayer.m +18 -14
- package/ios/MLRN/MLRNFillExtrusionLayerManager.m +4 -5
- package/ios/MLRN/MLRNFillLayer.m +16 -14
- package/ios/MLRN/MLRNFillLayerManager.m +4 -5
- package/ios/MLRN/MLRNHeatmapLayer.m +17 -14
- package/ios/MLRN/MLRNHeatmapLayerManager.m +4 -5
- package/ios/MLRN/MLRNImageQueue.h +4 -1
- package/ios/MLRN/MLRNImageQueue.m +29 -32
- package/ios/MLRN/MLRNImageQueueOperation.h +1 -1
- package/ios/MLRN/MLRNImageQueueOperation.m +92 -91
- package/ios/MLRN/MLRNImageSource.m +36 -38
- package/ios/MLRN/MLRNImageSourceManager.m +2 -3
- package/ios/MLRN/MLRNImageUtils.h +3 -3
- package/ios/MLRN/MLRNImageUtils.m +15 -14
- package/ios/MLRN/MLRNImages.h +0 -1
- package/ios/MLRN/MLRNImages.m +89 -91
- package/ios/MLRN/MLRNImagesManager.m +4 -5
- package/ios/MLRN/MLRNLayer.h +9 -11
- package/ios/MLRN/MLRNLayer.m +170 -182
- package/ios/MLRN/MLRNLight.m +21 -23
- package/ios/MLRN/MLRNLightManager.m +2 -3
- package/ios/MLRN/MLRNLineLayer.m +17 -15
- package/ios/MLRN/MLRNLineLayerManager.m +4 -6
- package/ios/MLRN/MLRNLocation.h +1 -1
- package/ios/MLRN/MLRNLocation.m +16 -17
- package/ios/MLRN/MLRNLocationManager.m +109 -124
- package/ios/MLRN/MLRNLocationManagerDelegate.h +3 -3
- package/ios/MLRN/MLRNLocationModule.h +1 -1
- package/ios/MLRN/MLRNLocationModule.m +40 -55
- package/ios/MLRN/MLRNLogging.h +1 -4
- package/ios/MLRN/MLRNLogging.m +84 -89
- package/ios/MLRN/MLRNMapTouchEvent.h +2 -2
- package/ios/MLRN/MLRNMapTouchEvent.m +50 -49
- package/ios/MLRN/MLRNMapView.h +43 -36
- package/ios/MLRN/MLRNMapView.m +409 -440
- package/ios/MLRN/MLRNMapViewManager.m +489 -502
- package/ios/MLRN/MLRNModule.h +1 -1
- package/ios/MLRN/MLRNModule.m +111 -105
- package/ios/MLRN/MLRNNativeUserLocation.m +24 -27
- package/ios/MLRN/MLRNNativeUserLocationManager.m +4 -8
- package/ios/MLRN/MLRNOfflineModule.h +1 -1
- package/ios/MLRN/MLRNOfflineModule.m +416 -421
- package/ios/MLRN/MLRNPointAnnotation.h +2 -2
- package/ios/MLRN/MLRNPointAnnotation.m +154 -175
- package/ios/MLRN/MLRNPointAnnotationManager.m +2 -3
- package/ios/MLRN/MLRNRasterLayer.m +16 -12
- package/ios/MLRN/MLRNRasterLayerManager.m +4 -5
- package/ios/MLRN/MLRNRasterSource.m +21 -17
- package/ios/MLRN/MLRNRasterSourceManager.m +2 -3
- package/ios/MLRN/MLRNShapeSource.h +17 -16
- package/ios/MLRN/MLRNShapeSource.m +94 -102
- package/ios/MLRN/MLRNShapeSourceManager.h +2 -2
- package/ios/MLRN/MLRNShapeSourceManager.m +86 -90
- package/ios/MLRN/MLRNSnapshotModule.h +1 -1
- package/ios/MLRN/MLRNSnapshotModule.m +51 -53
- package/ios/MLRN/MLRNSource.h +12 -12
- package/ios/MLRN/MLRNSource.m +82 -88
- package/ios/MLRN/MLRNStyleValue.h +1 -1
- package/ios/MLRN/MLRNStyleValue.m +128 -128
- package/ios/MLRN/MLRNSymbolLayer.m +17 -13
- package/ios/MLRN/MLRNSymbolLayerManager.m +4 -5
- package/ios/MLRN/MLRNTileSource.h +1 -1
- package/ios/MLRN/MLRNTileSource.m +21 -20
- package/ios/MLRN/MLRNUserLocation.h +1 -1
- package/ios/MLRN/MLRNUserLocation.m +10 -12
- package/ios/MLRN/MLRNUtils.h +18 -11
- package/ios/MLRN/MLRNUtils.m +168 -160
- package/ios/MLRN/MLRNVectorLayer.m +28 -34
- package/ios/MLRN/MLRNVectorSource.h +3 -1
- package/ios/MLRN/MLRNVectorSource.m +14 -11
- package/ios/MLRN/MLRNVectorSourceManager.h +2 -2
- package/ios/MLRN/MLRNVectorSourceManager.m +36 -39
- package/ios/MLRN/ViewManager.h +1 -1
- package/ios/MLRN/ViewManager.m +29 -35
- package/lib/commonjs/components/MarkerView.js +1 -1
- package/lib/commonjs/components/ShapeSource.js +2 -1
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/UserLocation.js +8 -38
- package/lib/commonjs/components/UserLocation.js.map +1 -1
- package/lib/commonjs/components/UserLocationPuck.js +52 -0
- package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
- package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
- package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +8 -7
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -2
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +28 -38
- package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedShape.js +11 -7
- package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/module/components/MarkerView.js +1 -1
- package/lib/module/components/ShapeSource.js +2 -1
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/UserLocation.js +7 -36
- package/lib/module/components/UserLocation.js.map +1 -1
- package/lib/module/components/UserLocationPuck.js +48 -0
- package/lib/module/components/UserLocationPuck.js.map +1 -0
- package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
- package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +8 -7
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -3
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +29 -39
- package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedShape.js +11 -7
- package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +8 -5
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +8 -5
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/MarkerView.tsx +1 -1
- package/src/components/ShapeSource.tsx +58 -53
- package/src/components/UserLocation.tsx +13 -51
- package/src/components/UserLocationPuck.tsx +62 -0
- package/src/components/UserLocationPuckHeading.tsx +33 -0
- package/src/utils/animated/AbstractAnimatedCoordinates.ts +26 -15
- package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +10 -6
- package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +63 -51
- package/src/utils/animated/AnimatedShape.ts +22 -13
- package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
- package/lib/module/components/HeadingIndicator.js.map +0 -1
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
- package/src/components/HeadingIndicator.tsx +0 -26
|
@@ -1,148 +1,140 @@
|
|
|
1
1
|
#import "MLRNShapeSource.h"
|
|
2
|
-
#import "MLRNUtils.h"
|
|
3
2
|
#import "MLRNMapView.h"
|
|
3
|
+
#import "MLRNUtils.h"
|
|
4
4
|
|
|
5
5
|
@implementation MLRNShapeSource
|
|
6
6
|
|
|
7
|
-
static UIImage *
|
|
7
|
+
static UIImage *_placeHolderImage;
|
|
8
8
|
|
|
9
|
-
- (void)setUrl:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
9
|
+
- (void)setUrl:(NSString *)url {
|
|
10
|
+
_url = url;
|
|
11
|
+
if (self.source != nil) {
|
|
12
|
+
MLNShapeSource *source = (MLNShapeSource *)self.source;
|
|
13
|
+
[source setURL:url == nil ? nil : [NSURL URLWithString:url]];
|
|
14
|
+
}
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
- (void)setShape:(NSString *)shape
|
|
19
|
-
|
|
20
|
-
_shape = shape;
|
|
17
|
+
- (void)setShape:(NSString *)shape {
|
|
18
|
+
_shape = shape;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (self.source != nil) {
|
|
21
|
+
MLNShapeSource *source = (MLNShapeSource *)self.source;
|
|
22
|
+
[source setShape:shape == nil ? nil : [MLRNUtils shapeFromGeoJSON:_shape]];
|
|
23
|
+
}
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
- (void)addToMap
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[super addToMap];
|
|
26
|
+
- (void)addToMap {
|
|
27
|
+
if (self.map.style == nil) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
[super addToMap];
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
- (void)removeFromMap
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
33
|
+
- (void)removeFromMap {
|
|
34
|
+
if (self.map.style == nil) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
[super removeFromMap];
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
- (nullable MLNSource*)makeSource
|
|
46
|
-
|
|
47
|
-
NSDictionary<MLNShapeSourceOption, id> *options = [self _getOptions];
|
|
41
|
+
- (nullable MLNSource *)makeSource {
|
|
42
|
+
NSDictionary<MLNShapeSourceOption, id> *options = [self _getOptions];
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
if (_shape != nil) {
|
|
45
|
+
MLNShape *shape = [MLRNUtils shapeFromGeoJSON:_shape];
|
|
46
|
+
return [[MLNShapeSource alloc] initWithIdentifier:self.id shape:shape options:options];
|
|
47
|
+
}
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
if (_url != nil) {
|
|
50
|
+
NSURL *url = [[NSURL alloc] initWithString:_url];
|
|
51
|
+
return [[MLNShapeSource alloc] initWithIdentifier:self.id URL:url options:options];
|
|
52
|
+
}
|
|
53
|
+
return nil;
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
- (NSDictionary<MLNShapeSourceOption, id
|
|
62
|
-
|
|
63
|
-
NSMutableDictionary<MLNShapeSourceOption, id> *options = [[NSMutableDictionary alloc] init];
|
|
56
|
+
- (NSDictionary<MLNShapeSourceOption, id> *)_getOptions {
|
|
57
|
+
NSMutableDictionary<MLNShapeSourceOption, id> *options = [[NSMutableDictionary alloc] init];
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
if (_cluster != nil) {
|
|
60
|
+
options[MLNShapeSourceOptionClustered] = [NSNumber numberWithBool:[_cluster intValue] == 1];
|
|
61
|
+
}
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
if (_clusterRadius != nil) {
|
|
64
|
+
options[MLNShapeSourceOptionClusterRadius] = _clusterRadius;
|
|
65
|
+
}
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
if (_clusterMaxZoomLevel != nil) {
|
|
68
|
+
options[MLNShapeSourceOptionMaximumZoomLevelForClustering] = _clusterMaxZoomLevel;
|
|
69
|
+
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
if (_clusterProperties != nil) {
|
|
72
|
+
NSMutableDictionary<NSString *, NSArray *> *properties = [NSMutableDictionary new];
|
|
79
73
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
for (NSString *propertyName in _clusterProperties.allKeys) {
|
|
75
|
+
NSArray<NSExpression *> *expressions = [_clusterProperties objectForKey:propertyName];
|
|
76
|
+
NSExpression *firstExpression =
|
|
77
|
+
[NSExpression expressionWithMLNJSONObject:[expressions objectAtIndex:0]];
|
|
78
|
+
NSExpression *secondExpression =
|
|
79
|
+
[NSExpression expressionWithMLNJSONObject:[expressions objectAtIndex:1]];
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
options[MLNShapeSourceOptionClusterProperties] = properties;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (_maxZoomLevel != nil) {
|
|
92
|
-
options[MLNShapeSourceOptionMaximumZoomLevel] = _maxZoomLevel;
|
|
81
|
+
[properties setObject:@[ firstExpression, secondExpression ] forKey:propertyName];
|
|
93
82
|
}
|
|
94
83
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
84
|
+
options[MLNShapeSourceOptionClusterProperties] = properties;
|
|
85
|
+
}
|
|
98
86
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
if (_maxZoomLevel != nil) {
|
|
88
|
+
options[MLNShapeSourceOptionMaximumZoomLevel] = _maxZoomLevel;
|
|
89
|
+
}
|
|
102
90
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
if (_buffer != nil) {
|
|
92
|
+
options[MLNShapeSourceOptionBuffer] = _buffer;
|
|
93
|
+
}
|
|
106
94
|
|
|
107
|
-
|
|
95
|
+
if (_tolerance != nil) {
|
|
96
|
+
options[MLNShapeSourceOptionSimplificationTolerance] = _tolerance;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (_lineMetrics != nil) {
|
|
100
|
+
options[MLNShapeSourceOptionLineDistanceMetrics] = _lineMetrics;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return options;
|
|
108
104
|
}
|
|
109
105
|
|
|
110
|
-
- (nonnull NSArray<id
|
|
111
|
-
|
|
112
|
-
MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
|
|
106
|
+
- (nonnull NSArray<id<MLNFeature>> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate {
|
|
107
|
+
MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
|
|
113
108
|
|
|
114
|
-
|
|
109
|
+
return [shapeSource featuresMatchingPredicate:predicate];
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
- (double)getClusterExpansionZoom:(nonnull NSString *)featureJSON
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
- (double)getClusterExpansionZoom:(nonnull NSString *)featureJSON {
|
|
113
|
+
MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
|
|
114
|
+
|
|
115
|
+
MLNPointFeature *feature = (MLNPointFeature *)[MLRNUtils shapeFromGeoJSON:featureJSON];
|
|
120
116
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return [shapeSource zoomLevelForExpandingCluster:(MLNPointFeatureCluster *)feature];
|
|
117
|
+
return [shapeSource zoomLevelForExpandingCluster:(MLNPointFeatureCluster *)feature];
|
|
124
118
|
}
|
|
125
119
|
|
|
126
|
-
- (nonnull NSArray<id
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
|
|
120
|
+
- (nonnull NSArray<id<MLNFeature>> *)getClusterLeaves:(nonnull NSString *)featureJSON
|
|
121
|
+
number:(NSUInteger)number
|
|
122
|
+
offset:(NSUInteger)offset {
|
|
123
|
+
MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
|
|
131
124
|
|
|
132
|
-
|
|
125
|
+
MLNPointFeature *feature = (MLNPointFeature *)[MLRNUtils shapeFromGeoJSON:featureJSON];
|
|
133
126
|
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
MLNPointFeatureCluster *cluster = (MLNPointFeatureCluster *)feature;
|
|
128
|
+
return [shapeSource leavesOfCluster:cluster offset:offset limit:number];
|
|
136
129
|
}
|
|
137
130
|
|
|
138
|
-
- (nonnull NSArray<id
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return [shapeSource childrenOfCluster:cluster];
|
|
131
|
+
- (nonnull NSArray<id<MLNFeature>> *)getClusterChildren:(nonnull NSString *)featureJSON {
|
|
132
|
+
MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
|
|
133
|
+
|
|
134
|
+
MLNPointFeature *feature = (MLNPointFeature *)[MLRNUtils shapeFromGeoJSON:featureJSON];
|
|
135
|
+
|
|
136
|
+
MLNPointFeatureCluster *cluster = (MLNPointFeatureCluster *)feature;
|
|
137
|
+
return [shapeSource childrenOfCluster:cluster];
|
|
146
138
|
}
|
|
147
139
|
|
|
148
140
|
@end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#import <React/RCTUIManager.h>
|
|
2
2
|
|
|
3
|
-
#import "MLRNShapeSourceManager.h"
|
|
4
3
|
#import "MLRNShapeSource.h"
|
|
4
|
+
#import "MLRNShapeSourceManager.h"
|
|
5
5
|
|
|
6
6
|
#import "FilterParser.h"
|
|
7
7
|
|
|
@@ -27,105 +27,101 @@ RCT_EXPORT_VIEW_PROPERTY(hasPressListener, BOOL)
|
|
|
27
27
|
RCT_EXPORT_VIEW_PROPERTY(hitbox, NSDictionary)
|
|
28
28
|
RCT_REMAP_VIEW_PROPERTY(onMapboxShapeSourcePress, onPress, RCTBubblingEventBlock)
|
|
29
29
|
|
|
30
|
-
- (UIView*)view
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return source;
|
|
30
|
+
- (UIView *)view {
|
|
31
|
+
MLRNShapeSource *source = [MLRNShapeSource new];
|
|
32
|
+
source.bridge = self.bridge;
|
|
33
|
+
return source;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
RCT_EXPORT_METHOD(features:(nonnull NSNumber*)reactTag
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
36
|
+
RCT_EXPORT_METHOD(features : (nonnull NSNumber *)reactTag withFilter : (NSArray *)
|
|
37
|
+
filter resolver : (RCTPromiseResolveBlock)
|
|
38
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
39
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
40
|
+
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
41
|
+
UIView *view = viewRegistry[reactTag];
|
|
42
|
+
MLRNShapeSource *shapeSource = nil;
|
|
43
|
+
|
|
44
|
+
if ([shapeSource isKindOfClass:[MLRNShapeSource class]]) {
|
|
45
|
+
shapeSource = (MLRNShapeSource *)view;
|
|
46
|
+
} else {
|
|
47
|
+
RCTLogError(@"Invalid react tag, could not find MLRNMapView");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
NSPredicate *predicate = [FilterParser parse:filter];
|
|
52
|
+
NSArray<id<MLNFeature>> *shapes = [shapeSource featuresMatchingPredicate:predicate];
|
|
53
|
+
|
|
54
|
+
NSMutableArray<NSDictionary *> *features =
|
|
55
|
+
[[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
56
|
+
for (int i = 0; i < shapes.count; i++) {
|
|
57
|
+
[features addObject:shapes[i].geoJSONDictionary];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
resolve(@{@"data" : @{@"type" : @"FeatureCollection", @"features" : features}});
|
|
61
|
+
}];
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
RCT_EXPORT_METHOD(getClusterExpansionZoom:(nonnull NSNumber*)reactTag
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
RCT_EXPORT_METHOD(getClusterExpansionZoom : (nonnull NSNumber *)reactTag featureJSON : (
|
|
65
|
+
nonnull NSString *)featureJSON resolver : (RCTPromiseResolveBlock)
|
|
66
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
67
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
68
|
+
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
69
|
+
MLRNShapeSource *shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
70
|
+
|
|
71
|
+
if (![shapeSource isKindOfClass:[MLRNShapeSource class]]) {
|
|
72
|
+
RCTLogError(@"Invalid react tag, could not find MLRNMapView");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
double zoom = [shapeSource getClusterExpansionZoom:featureJSON];
|
|
77
|
+
if (zoom == -1) {
|
|
78
|
+
reject(@"zoom_error",
|
|
79
|
+
[NSString stringWithFormat:@"Could not get zoom for cluster %@", featureJSON], nil);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
resolve(@{@"data" : @(zoom)});
|
|
83
|
+
}];
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
RCT_EXPORT_METHOD(getClusterLeaves : (nonnull NSNumber *)reactTag featureJSON : (nonnull NSString *)
|
|
87
|
+
featureJSON number : (NSUInteger)number offset : (NSUInteger)
|
|
88
|
+
offset resolver : (RCTPromiseResolveBlock)
|
|
89
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
90
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
91
|
+
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
92
|
+
MLRNShapeSource *shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
93
|
+
|
|
94
|
+
NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterLeaves:featureJSON
|
|
95
|
+
number:number
|
|
96
|
+
offset:offset];
|
|
97
|
+
|
|
98
|
+
NSMutableArray<NSDictionary *> *features =
|
|
99
|
+
[[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
100
|
+
for (int i = 0; i < shapes.count; i++) {
|
|
101
|
+
[features addObject:shapes[i].geoJSONDictionary];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
resolve(@{@"data" : @{@"type" : @"FeatureCollection", @"features" : features}});
|
|
105
|
+
}];
|
|
106
|
+
}
|
|
86
107
|
|
|
87
|
-
RCT_EXPORT_METHOD(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary<NSNumber*, UIView*> *viewRegistry) {
|
|
95
|
-
MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
96
|
-
|
|
97
|
-
NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterLeaves:featureJSON number:number offset:offset];
|
|
108
|
+
RCT_EXPORT_METHOD(getClusterChildren : (nonnull NSNumber *)reactTag featureJSON : (
|
|
109
|
+
nonnull NSString *)featureJSON resolver : (RCTPromiseResolveBlock)
|
|
110
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
111
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
112
|
+
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
113
|
+
MLRNShapeSource *shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
98
114
|
|
|
99
|
-
|
|
100
|
-
for (int i = 0; i < shapes.count; i++) {
|
|
101
|
-
[features addObject:shapes[i].geoJSONDictionary];
|
|
102
|
-
}
|
|
115
|
+
NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterChildren:featureJSON];
|
|
103
116
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
117
|
+
NSMutableArray<NSDictionary *> *features =
|
|
118
|
+
[[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
119
|
+
for (int i = 0; i < shapes.count; i++) {
|
|
120
|
+
[features addObject:shapes[i].geoJSONDictionary];
|
|
121
|
+
}
|
|
109
122
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
113
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
114
|
-
{
|
|
115
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary<NSNumber*, UIView*> *viewRegistry) {
|
|
116
|
-
MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
117
|
-
|
|
118
|
-
NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterChildren: featureJSON];
|
|
119
|
-
|
|
120
|
-
NSMutableArray<NSDictionary*> *features = [[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
121
|
-
for (int i = 0; i < shapes.count; i++) {
|
|
122
|
-
[features addObject:shapes[i].geoJSONDictionary];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
resolve(@{
|
|
126
|
-
@"data": @{ @"type": @"FeatureCollection", @"features": features }
|
|
127
|
-
});
|
|
128
|
-
}];
|
|
123
|
+
resolve(@{@"data" : @{@"type" : @"FeatureCollection", @"features" : features}});
|
|
124
|
+
}];
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
@end
|
|
@@ -1,72 +1,70 @@
|
|
|
1
1
|
#import "MLRNSnapshotModule.h"
|
|
2
|
-
#import "MLRNUtils.h"
|
|
3
2
|
#import "MLRNImageUtils.h"
|
|
3
|
+
#import "MLRNUtils.h"
|
|
4
4
|
@import MapLibre;
|
|
5
5
|
|
|
6
6
|
@implementation MLRNSnapshotModule
|
|
7
7
|
|
|
8
8
|
RCT_EXPORT_MODULE()
|
|
9
9
|
|
|
10
|
-
+ (BOOL)requiresMainQueueSetup
|
|
11
|
-
|
|
12
|
-
return YES;
|
|
10
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
11
|
+
return YES;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
RCT_EXPORT_METHOD(takeSnap:(NSDictionary *)jsOptions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
MLNMapSnapshotOptions *options = [self _getOptions:jsOptions];
|
|
21
|
-
__block MLNMapSnapshotter *snapshotter = [[MLNMapSnapshotter alloc] initWithOptions:options];
|
|
14
|
+
RCT_EXPORT_METHOD(takeSnap : (NSDictionary *)jsOptions resolver : (RCTPromiseResolveBlock)
|
|
15
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
16
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
17
|
+
MLNMapSnapshotOptions *options = [self _getOptions:jsOptions];
|
|
18
|
+
__block MLNMapSnapshotter *snapshotter = [[MLNMapSnapshotter alloc] initWithOptions:options];
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
NSString *result = nil;
|
|
31
|
-
if ([jsOptions[@"writeToDisk"] boolValue]) {
|
|
32
|
-
result = [MLRNImageUtils createTempFile:snapshot.image];
|
|
33
|
-
} else {
|
|
34
|
-
result = [MLRNImageUtils createBase64:snapshot.image];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
resolve(result);
|
|
20
|
+
[snapshotter
|
|
21
|
+
startWithCompletionHandler:^(MLNMapSnapshot *_Nullable snapshot, NSError *_Nullable err) {
|
|
22
|
+
if (err != nil) {
|
|
23
|
+
reject(@"takeSnap", @"Could not create snapshot", err);
|
|
38
24
|
snapshotter = nil;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
NSString *result = nil;
|
|
29
|
+
if ([jsOptions[@"writeToDisk"] boolValue]) {
|
|
30
|
+
result = [MLRNImageUtils createTempFile:snapshot.image];
|
|
31
|
+
} else {
|
|
32
|
+
result = [MLRNImageUtils createBase64:snapshot.image];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
resolve(result);
|
|
36
|
+
snapshotter = nil;
|
|
39
37
|
}];
|
|
40
|
-
|
|
38
|
+
});
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
- (MLNMapSnapshotOptions *)_getOptions:(NSDictionary *)jsOptions
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
- (MLNMapSnapshotOptions *)_getOptions:(NSDictionary *)jsOptions {
|
|
42
|
+
MLNMapCamera *camera = [[MLNMapCamera alloc] init];
|
|
43
|
+
|
|
44
|
+
camera.pitch = [jsOptions[@"pitch"] doubleValue];
|
|
45
|
+
camera.heading = [jsOptions[@"heading"] doubleValue];
|
|
46
|
+
|
|
47
|
+
if (jsOptions[@"centerCoordinate"] != nil) {
|
|
48
|
+
camera.centerCoordinate = [MLRNUtils fromFeature:jsOptions[@"centerCoordinate"]];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
NSNumber *width = jsOptions[@"width"];
|
|
52
|
+
NSNumber *height = jsOptions[@"height"];
|
|
53
|
+
CGSize size = CGSizeMake([width doubleValue], [height doubleValue]);
|
|
54
|
+
|
|
55
|
+
MLNMapSnapshotOptions *options =
|
|
56
|
+
[[MLNMapSnapshotOptions alloc] initWithStyleURL:[NSURL URLWithString:jsOptions[@"styleURL"]]
|
|
57
|
+
camera:camera
|
|
58
|
+
size:size];
|
|
59
|
+
if (jsOptions[@"zoomLevel"] != nil) {
|
|
60
|
+
options.zoomLevel = [jsOptions[@"zoomLevel"] doubleValue];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (jsOptions[@"bounds"] != nil) {
|
|
64
|
+
options.coordinateBounds = [MLRNUtils fromFeatureCollection:jsOptions[@"bounds"]];
|
|
65
|
+
}
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
return options;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
@end
|
package/ios/MLRN/MLRNSource.h
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
#import <React/RCTComponent.h>
|
|
2
|
-
#import "MLRNLayer.h"
|
|
3
2
|
#import <UIKit/UIKit.h>
|
|
3
|
+
#import "MLRNLayer.h"
|
|
4
4
|
@import MapLibre;
|
|
5
5
|
|
|
6
6
|
@interface MLRNSource : UIView
|
|
7
7
|
|
|
8
|
-
extern NSString *
|
|
8
|
+
extern NSString *_Nonnull const DEFAULT_SOURCE_ID;
|
|
9
9
|
|
|
10
|
-
@property (nonatomic, strong) NSMutableArray<id<RCTComponent>> *reactSubviews;
|
|
11
|
-
@property (nonatomic, strong) NSMutableArray<MLRNLayer*> *layers;
|
|
12
|
-
@property (nonatomic, strong) MLNSource *source;
|
|
13
|
-
@property (nonatomic, strong) MLRNMapView *map;
|
|
14
|
-
@property (nonatomic, strong) NSDictionary<NSString *, NSNumber *> *hitbox;
|
|
10
|
+
@property (nonatomic, strong, nonnull) NSMutableArray<id<RCTComponent>> *reactSubviews;
|
|
11
|
+
@property (nonatomic, strong, nonnull) NSMutableArray<MLRNLayer *> *layers;
|
|
12
|
+
@property (nonatomic, strong, nullable) MLNSource *source;
|
|
13
|
+
@property (nonatomic, strong, nullable) MLRNMapView *map;
|
|
14
|
+
@property (nonatomic, strong, nonnull) NSDictionary<NSString *, NSNumber *> *hitbox;
|
|
15
15
|
|
|
16
|
-
@property (nonatomic, copy) NSString *id;
|
|
16
|
+
@property (nonatomic, copy, nonnull) NSString *id;
|
|
17
17
|
@property (nonatomic, assign) BOOL hasPressListener;
|
|
18
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
|
18
|
+
@property (nonatomic, copy, nullable) RCTBubblingEventBlock onPress;
|
|
19
19
|
|
|
20
20
|
- (void)addToMap;
|
|
21
21
|
- (void)removeFromMap;
|
|
22
|
-
- (nullable MLNSource*)makeSource;
|
|
23
|
-
- (NSArray<NSString *> *)getLayerIDs;
|
|
22
|
+
- (nullable MLNSource *)makeSource;
|
|
23
|
+
- (nonnull NSArray<NSString *> *)getLayerIDs;
|
|
24
24
|
|
|
25
|
-
+ (BOOL)isDefaultSource:(NSString*)sourceID;
|
|
25
|
+
+ (BOOL)isDefaultSource:(nonnull NSString *)sourceID;
|
|
26
26
|
|
|
27
27
|
@end
|