@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
|
@@ -12,27 +12,25 @@
|
|
|
12
12
|
|
|
13
13
|
@implementation HiddenUserLocationAnnotationView
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
- (void)update {
|
|
17
|
-
|
|
16
|
+
self.frame = CGRectNull;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
@end
|
|
21
20
|
|
|
22
|
-
|
|
23
21
|
@implementation MLRNUserLocation : NSObject
|
|
24
22
|
|
|
25
|
-
+ (id)sharedInstance
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
+ (id)sharedInstance {
|
|
24
|
+
static MLRNUserLocation *userLocation = nil;
|
|
25
|
+
static dispatch_once_t onceToken;
|
|
26
|
+
dispatch_once(&onceToken, ^{
|
|
27
|
+
userLocation = [[self alloc] init];
|
|
28
|
+
});
|
|
29
|
+
return userLocation;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
- (MLNUserLocationAnnotationView*)hiddenUserAnnotation
|
|
34
|
-
|
|
35
|
-
return [[HiddenUserLocationAnnotationView alloc] init];
|
|
32
|
+
- (MLNUserLocationAnnotationView *)hiddenUserAnnotation {
|
|
33
|
+
return [[HiddenUserLocationAnnotationView alloc] init];
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
@end
|
package/ios/MLRN/MLRNUtils.h
CHANGED
|
@@ -5,19 +5,26 @@
|
|
|
5
5
|
|
|
6
6
|
@import MapLibre;
|
|
7
7
|
|
|
8
|
-
@interface MLRNUtils: NSObject
|
|
8
|
+
@interface MLRNUtils : NSObject
|
|
9
9
|
|
|
10
|
-
+ (CLLocationCoordinate2D)fromFeature:(NSString*)json;
|
|
11
|
-
+ (MLNShape*)shapeFromGeoJSON:(NSString*)json;
|
|
12
|
-
+ (MLNCoordinateBounds)fromFeatureCollection:(NSString*)json;
|
|
10
|
+
+ (CLLocationCoordinate2D)fromFeature:(NSString *)json;
|
|
11
|
+
+ (MLNShape *)shapeFromGeoJSON:(NSString *)json;
|
|
12
|
+
+ (MLNCoordinateBounds)fromFeatureCollection:(NSString *)json;
|
|
13
13
|
+ (NSArray<NSNumber *> *)fromCoordinateBounds:(MLNCoordinateBounds)bounds;
|
|
14
|
-
+ (NSTimeInterval)fromMS:(NSNumber*)number;
|
|
15
|
-
+ (NSNumber*)clamp:(NSNumber*)value min:(NSNumber*)min max:(NSNumber*)max;
|
|
16
|
-
+ (UIColor*)toColor:(id)value;
|
|
17
|
-
+ (void)fetchImage:(RCTBridge*)bridge
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
+ (NSTimeInterval)fromMS:(NSNumber *)number;
|
|
15
|
+
+ (NSNumber *)clamp:(NSNumber *)value min:(NSNumber *)min max:(NSNumber *)max;
|
|
16
|
+
+ (UIColor *)toColor:(id)value;
|
|
17
|
+
+ (void)fetchImage:(RCTBridge *)bridge
|
|
18
|
+
url:(NSString *)url
|
|
19
|
+
scale:(double)scale
|
|
20
|
+
callback:(RCTImageLoaderCompletionBlock)callback;
|
|
21
|
+
+ (void)fetchImages:(RCTBridge *)bridge
|
|
22
|
+
style:(MLNStyle *)style
|
|
23
|
+
objects:(NSDictionary<NSString *, NSString *> *)objects
|
|
24
|
+
forceUpdate:(BOOL)forceUpdate
|
|
25
|
+
callback:(void (^)(void))callback;
|
|
26
|
+
+ (CGVector)toCGVector:(NSArray<NSNumber *> *)arr;
|
|
20
27
|
+ (UIEdgeInsets)toUIEdgeInsets:(NSArray<NSNumber *> *)arr;
|
|
21
|
-
+ (NSURL*)styleURLFromStyleJSON:(NSString *)styleJSON;
|
|
28
|
+
+ (NSURL *)styleURLFromStyleJSON:(NSString *)styleJSON;
|
|
22
29
|
|
|
23
30
|
@end
|
package/ios/MLRN/MLRNUtils.m
CHANGED
|
@@ -7,204 +7,212 @@
|
|
|
7
7
|
|
|
8
8
|
static double const MS_TO_S = 0.001;
|
|
9
9
|
|
|
10
|
-
+ (CLLocationCoordinate2D)fromFeature:(NSString*)jsonStr
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
+ (CLLocationCoordinate2D)fromFeature:(NSString *)jsonStr {
|
|
11
|
+
NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
|
|
12
|
+
MLNPointFeature *feature = (MLNPointFeature *)[MLNShape shapeWithData:data
|
|
13
|
+
encoding:NSUTF8StringEncoding
|
|
14
|
+
error:nil];
|
|
15
|
+
return feature.coordinate;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
+ (UIEdgeInsets)toUIEdgeInsets:(NSArray<NSNumber *> *)arr
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
+ (UIEdgeInsets)toUIEdgeInsets:(NSArray<NSNumber *> *)arr {
|
|
19
|
+
return UIEdgeInsetsMake([arr[0] floatValue], [arr[1] floatValue], [arr[2] floatValue],
|
|
20
|
+
[arr[3] floatValue]);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
+ (MLNShape*)shapeFromGeoJSON:(NSString*)jsonStr
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return result;
|
|
23
|
+
+ (MLNShape *)shapeFromGeoJSON:(NSString *)jsonStr {
|
|
24
|
+
NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
|
|
25
|
+
NSError *error = nil;
|
|
26
|
+
MLNShape *result = [MLNShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
|
|
27
|
+
if (error != nil) {
|
|
28
|
+
RCTLogWarn(@"Failed to convert data to shape error:%@ src:%@", error, jsonStr);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
+ (NSString *)hashURI:(NSString *)uri
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return [NSString stringWithFormat:@"%lu", (unsigned long)hash];
|
|
33
|
+
+ (NSString *)hashURI:(NSString *)uri {
|
|
34
|
+
if (uri == nil) {
|
|
35
|
+
return @"-1";
|
|
36
|
+
}
|
|
37
|
+
NSUInteger hash = [uri hash];
|
|
38
|
+
return [NSString stringWithFormat:@"%lu", (unsigned long)hash];
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
+ (MLNCoordinateBounds)fromFeatureCollection:(NSString*)jsonStr
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
+ (MLNCoordinateBounds)fromFeatureCollection:(NSString *)jsonStr {
|
|
42
|
+
NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
|
|
43
|
+
MLNShapeCollectionFeature *featureCollection =
|
|
44
|
+
(MLNShapeCollectionFeature *)[MLNShapeCollectionFeature shapeWithData:data
|
|
45
|
+
encoding:NSUTF8StringEncoding
|
|
46
|
+
error:nil];
|
|
47
|
+
|
|
48
|
+
CLLocationCoordinate2D ne = featureCollection.shapes[0].coordinate;
|
|
49
|
+
CLLocationCoordinate2D sw = featureCollection.shapes[1].coordinate;
|
|
50
|
+
|
|
51
|
+
return MLNCoordinateBoundsMake(sw, ne);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
+ (NSArray<NSNumber *> *)fromCoordinateBounds:(MLNCoordinateBounds)bounds
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
];
|
|
54
|
+
+ (NSArray<NSNumber *> *)fromCoordinateBounds:(MLNCoordinateBounds)bounds {
|
|
55
|
+
return @[
|
|
56
|
+
@[ @(bounds.ne.longitude), @(bounds.ne.latitude) ],
|
|
57
|
+
@[ @(bounds.sw.longitude), @(bounds.sw.latitude) ]
|
|
58
|
+
];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
+ (NSTimeInterval)fromMS:(NSNumber *)number
|
|
62
|
-
|
|
63
|
-
return [number doubleValue] * MS_TO_S;
|
|
61
|
+
+ (NSTimeInterval)fromMS:(NSNumber *)number {
|
|
62
|
+
return [number doubleValue] * MS_TO_S;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
+ (NSNumber*)clamp:(NSNumber *)value min:(NSNumber *)min max:(NSNumber *)max
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return value;
|
|
65
|
+
+ (NSNumber *)clamp:(NSNumber *)value min:(NSNumber *)min max:(NSNumber *)max {
|
|
66
|
+
if ([value doubleValue] < [min doubleValue]) return min;
|
|
67
|
+
if ([value doubleValue] > [max doubleValue]) return max;
|
|
68
|
+
return value;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
+ (UIColor*)toColor:(id)value
|
|
74
|
-
|
|
75
|
-
return [RCTConvert UIColor:value];
|
|
71
|
+
+ (UIColor *)toColor:(id)value {
|
|
72
|
+
return [RCTConvert UIColor:value];
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
+ (CGVector)toCGVector:(NSArray<NSNumber *> *)arr
|
|
79
|
-
|
|
80
|
-
return CGVectorMake([arr[0] floatValue], [arr[1] floatValue]);
|
|
75
|
+
+ (CGVector)toCGVector:(NSArray<NSNumber *> *)arr {
|
|
76
|
+
return CGVectorMake([arr[0] floatValue], [arr[1] floatValue]);
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
+ (void)fetchImage:(RCTBridge*)bridge
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
+ (void)fetchImage:(RCTBridge *)bridge
|
|
80
|
+
url:(NSString *)url
|
|
81
|
+
scale:(double)scale
|
|
82
|
+
callback:(RCTImageLoaderCompletionBlock)callback {
|
|
83
|
+
[MLRNImageQueue.sharedInstance addImage:url scale:scale bridge:bridge completionHandler:callback];
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
+ (void)fetchImages:(RCTBridge *)bridge
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
+ (void)fetchImages:(RCTBridge *)bridge
|
|
87
|
+
style:(MLNStyle *)style
|
|
88
|
+
objects:(NSDictionary<NSString *, id> *)objects
|
|
89
|
+
forceUpdate:(BOOL)forceUpdate
|
|
90
|
+
callback:(void (^)(void))callback {
|
|
91
|
+
if (objects == nil) {
|
|
92
|
+
callback();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
NSArray<NSString *> *imageNames = objects.allKeys;
|
|
97
|
+
if (imageNames.count == 0) {
|
|
98
|
+
callback();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
__block NSUInteger imagesLeftToLoad = imageNames.count;
|
|
103
|
+
__weak MLNStyle *weakStyle = style;
|
|
104
|
+
|
|
105
|
+
void (^imageLoadedBlock)(void) = ^{
|
|
106
|
+
imagesLeftToLoad--;
|
|
107
|
+
|
|
108
|
+
if (imagesLeftToLoad == 0) {
|
|
109
|
+
callback();
|
|
93
110
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
[MLRNImageQueue.sharedInstance addImage:objects[imageName] scale:scale bridge:bridge completionHandler:^(NSError *error, UIImage *image) {
|
|
120
|
-
if (!image) {
|
|
121
|
-
RCTLogWarn(@"Failed to fetch image: %@ error:%@", imageName, error);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
125
|
-
[weakStyle setImage:image forName:imageName];
|
|
126
|
-
imageLoadedBlock();
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}];
|
|
130
|
-
} else {
|
|
131
|
-
imageLoadedBlock();
|
|
132
|
-
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
for (NSString *imageName in imageNames) {
|
|
114
|
+
UIImage *foundImage = forceUpdate ? nil : [style imageForName:imageName];
|
|
115
|
+
|
|
116
|
+
if (forceUpdate || foundImage == nil) {
|
|
117
|
+
NSDictionary *image = objects[imageName];
|
|
118
|
+
BOOL hasScale =
|
|
119
|
+
[image isKindOfClass:[NSDictionary class]] && ([image objectForKey:@"scale"] != nil);
|
|
120
|
+
double scale = hasScale ? [[image objectForKey:@"scale"] doubleValue] : 1.0;
|
|
121
|
+
[MLRNImageQueue.sharedInstance addImage:objects[imageName]
|
|
122
|
+
scale:scale
|
|
123
|
+
bridge:bridge
|
|
124
|
+
completionHandler:^(NSError *error, UIImage *image) {
|
|
125
|
+
if (!image) {
|
|
126
|
+
RCTLogWarn(@"Failed to fetch image: %@ error:%@", imageName, error);
|
|
127
|
+
} else {
|
|
128
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
129
|
+
[weakStyle setImage:image forName:imageName];
|
|
130
|
+
imageLoadedBlock();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}];
|
|
134
|
+
} else {
|
|
135
|
+
imageLoadedBlock();
|
|
133
136
|
}
|
|
137
|
+
}
|
|
134
138
|
}
|
|
135
139
|
|
|
136
|
-
+ (NSString*)getStyleJsonTempDirectory
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
+ (NSString *)getStyleJsonTempDirectory {
|
|
141
|
+
static NSString *styleJsonTempDirectory;
|
|
142
|
+
if (!styleJsonTempDirectory) {
|
|
143
|
+
styleJsonTempDirectory =
|
|
144
|
+
[NSTemporaryDirectory() stringByAppendingPathComponent:@"MLRNStyleJSON"];
|
|
145
|
+
}
|
|
146
|
+
return styleJsonTempDirectory;
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
/**
|
|
146
|
-
* Clears cached style-json entries from previous app runs. Can be safely called multiple times as
|
|
147
|
-
* only perform the action once per app run.
|
|
150
|
+
* Clears cached style-json entries from previous app runs. Can be safely called multiple times as
|
|
151
|
+
* it will only perform the action once per app run.
|
|
148
152
|
*
|
|
149
153
|
* @see styleURLFromStyleJSON:
|
|
150
154
|
*/
|
|
151
|
-
+ (void)cleanCustomStyleJSONCacheIfNeeded
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
155
|
+
+ (void)cleanCustomStyleJSONCacheIfNeeded {
|
|
156
|
+
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
157
|
+
NSString *styleJsonTempDirectory = [MLRNUtils getStyleJsonTempDirectory];
|
|
158
|
+
|
|
159
|
+
static dispatch_once_t onceToken;
|
|
160
|
+
dispatch_once(&onceToken, ^{
|
|
161
|
+
if ([fileManager fileExistsAtPath:styleJsonTempDirectory]) {
|
|
162
|
+
[fileManager removeItemAtPath:styleJsonTempDirectory error:NULL];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
/**
|
|
165
|
-
* Provides a way to convert raw style-json into a file so it can be directly referenced / used as
|
|
166
|
-
* It's a crude / alternative approach to support Android's API: Style.Builder.fromJson().
|
|
168
|
+
* Provides a way to convert raw style-json into a file so it can be directly referenced / used as
|
|
169
|
+
* styleURL. It's a crude / alternative approach to support Android's API: Style.Builder.fromJson().
|
|
167
170
|
*/
|
|
168
|
-
+ (NSURL*)styleURLFromStyleJSON:(NSString *)styleJSON
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
171
|
+
+ (NSURL *)styleURLFromStyleJSON:(NSString *)styleJSON {
|
|
172
|
+
[MLRNUtils cleanCustomStyleJSONCacheIfNeeded];
|
|
173
|
+
|
|
174
|
+
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
175
|
+
NSString *styleJsonTempDirectory = [MLRNUtils getStyleJsonTempDirectory];
|
|
176
|
+
|
|
177
|
+
// attempt to create the temporary directory
|
|
178
|
+
if (![fileManager fileExistsAtPath:styleJsonTempDirectory]) {
|
|
179
|
+
NSError *error;
|
|
180
|
+
[fileManager createDirectoryAtPath:styleJsonTempDirectory
|
|
181
|
+
withIntermediateDirectories:YES
|
|
182
|
+
attributes:nil
|
|
183
|
+
error:&error];
|
|
184
|
+
if (error) {
|
|
185
|
+
RCTLogError(@"Failed to create temporary directory '%@' for storing style-json. Error: %@",
|
|
186
|
+
styleJsonTempDirectory, error);
|
|
187
|
+
return nil;
|
|
186
188
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Determine filename based on the md5 hash of the style-json.
|
|
192
|
+
// This way, the written file can also act as a cached entry in case
|
|
193
|
+
// the same style-json is used again.
|
|
194
|
+
NSString *hashedFilename = [RCTMD5Hash(styleJSON) stringByAppendingPathExtension:@"json"];
|
|
195
|
+
|
|
196
|
+
// Construct temporary file path (tempdir + md5 hash for filename)
|
|
197
|
+
NSString *styleJsonTempPath =
|
|
198
|
+
[styleJsonTempDirectory stringByAppendingPathComponent:hashedFilename];
|
|
199
|
+
NSURL *styleJsonTempURL = [NSURL fileURLWithPath:styleJsonTempPath isDirectory:false];
|
|
200
|
+
|
|
201
|
+
// Write style-json to temporary file in case it doesn't already exist
|
|
202
|
+
if (![fileManager fileExistsAtPath:styleJsonTempPath isDirectory:false]) {
|
|
203
|
+
NSError *error;
|
|
204
|
+
[styleJSON writeToURL:styleJsonTempURL
|
|
205
|
+
atomically:YES
|
|
206
|
+
encoding:NSUTF8StringEncoding
|
|
207
|
+
error:&error];
|
|
208
|
+
if (error) {
|
|
209
|
+
RCTLogError(@"Failed to write style-json to temporary file '%@'. Error: %@", styleJsonTempURL,
|
|
210
|
+
error);
|
|
211
|
+
return nil;
|
|
205
212
|
}
|
|
206
|
-
|
|
207
|
-
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return styleJsonTempURL;
|
|
208
216
|
}
|
|
209
217
|
|
|
210
218
|
@end
|
|
@@ -1,51 +1,45 @@
|
|
|
1
1
|
#import "MLRNVectorLayer.h"
|
|
2
|
-
#import "MLRNStyle.h"
|
|
3
|
-
#import "FilterParser.h"
|
|
4
2
|
#import <React/RCTLog.h>
|
|
3
|
+
#import "FilterParser.h"
|
|
4
|
+
#import "MLRNStyle.h"
|
|
5
5
|
|
|
6
6
|
@implementation MLRNVectorLayer
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
return self.filter ? [FilterParser parse:self.filter] : nil;
|
|
8
|
+
- (NSPredicate *)buildFilters {
|
|
9
|
+
return self.filter ? [FilterParser parse:self.filter] : nil;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
- (void)updateFilter:(NSPredicate *)predicate
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
12
|
+
- (void)updateFilter:(NSPredicate *)predicate {
|
|
13
|
+
@try {
|
|
14
|
+
((MLNVectorStyleLayer *)self.styleLayer).predicate = predicate;
|
|
15
|
+
} @catch (NSException *exception) {
|
|
16
|
+
RCTLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self,
|
|
17
|
+
exception.name, exception.reason);
|
|
18
|
+
}
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
- (void)setSourceLayerID:(NSString *)sourceLayerID
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
21
|
+
- (void)setSourceLayerID:(NSString *)sourceLayerID {
|
|
22
|
+
_sourceLayerID = sourceLayerID;
|
|
23
|
+
|
|
24
|
+
if (self.styleLayer != nil) {
|
|
25
|
+
((MLNVectorStyleLayer *)self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
|
|
26
|
+
}
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
- (void)addedToMap
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
29
|
+
- (void)addedToMap {
|
|
30
|
+
NSPredicate *filter = [self buildFilters];
|
|
31
|
+
if (filter != nil) {
|
|
32
|
+
[self updateFilter:filter];
|
|
33
|
+
}
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
- (void)setFilter:(NSArray*)filter
|
|
42
|
-
|
|
43
|
-
[super setFilter: filter];
|
|
36
|
+
- (void)setFilter:(NSArray *)filter {
|
|
37
|
+
[super setFilter:filter];
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
if (self.styleLayer != nil) {
|
|
40
|
+
NSPredicate *predicate = [self buildFilters];
|
|
41
|
+
[self updateFilter:predicate];
|
|
42
|
+
}
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
@end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
@interface MLRNVectorSource : MLRNTileSource
|
|
5
5
|
|
|
6
|
-
- (nonnull NSArray<id
|
|
6
|
+
- (nonnull NSArray<id<MLNFeature>> *)
|
|
7
|
+
featuresInSourceLayersWithIdentifiers:(nonnull NSSet<NSString *> *)sourceLayerIdentifiers
|
|
8
|
+
predicate:(nullable NSPredicate *)predicate;
|
|
7
9
|
|
|
8
10
|
@end
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation MLRNVectorSource
|
|
4
4
|
|
|
5
|
-
- (nullable MLNSource*)makeSource
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
- (nullable MLNSource *)makeSource {
|
|
6
|
+
if (self.url != nil) {
|
|
7
|
+
return [[MLNVectorTileSource alloc] initWithIdentifier:self.id configurationURLString:self.url];
|
|
8
|
+
}
|
|
9
|
+
return [[MLNVectorTileSource alloc] initWithIdentifier:self.id
|
|
10
|
+
tileURLTemplates:self.tileUrlTemplates
|
|
11
|
+
options:[self getOptions]];
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
- (nonnull NSArray<id
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
- (nonnull NSArray<id<MLNFeature>> *)
|
|
15
|
+
featuresInSourceLayersWithIdentifiers:(nonnull NSSet<NSString *> *)sourceLayerIdentifiers
|
|
16
|
+
predicate:(nullable NSPredicate *)predicate {
|
|
17
|
+
MLNVectorTileSource *vectorSource = (MLNVectorTileSource *)self.source;
|
|
18
|
+
|
|
19
|
+
return [vectorSource featuresInSourceLayersWithIdentifiers:sourceLayerIdentifiers
|
|
20
|
+
predicate:predicate];
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
@end
|