react-native-ipostmap-navigation 1.0.1 → 1.0.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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#import <Map4dServices/Map4dServices.h>
|
|
3
3
|
#import <Map4dNavigation/Map4dNavigation.h>
|
|
4
4
|
#import <React/RCTUtils.h>
|
|
5
|
-
#import "
|
|
5
|
+
#import "NParamConvert.h"
|
|
6
6
|
|
|
7
7
|
@interface MFDirectionsResult (Extension)
|
|
8
8
|
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
return nil;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
MFLocationComponent *origin = [
|
|
78
|
-
MFLocationComponent *destination = [
|
|
77
|
+
MFLocationComponent *origin = [NParamConvert MFLocationComponent:dict[@"origin"]];
|
|
78
|
+
MFLocationComponent *destination = [NParamConvert MFLocationComponent:dict[@"destination"]];
|
|
79
79
|
MFDirectionsParams *params = [[MFDirectionsParams alloc] initWithOrigin:origin destination:destination];
|
|
80
|
-
params.mode = [
|
|
81
|
-
params.waypoints = [
|
|
82
|
-
params.language = [
|
|
83
|
-
params.weighting = [
|
|
84
|
-
params.restriction = [
|
|
80
|
+
params.mode = [NParamConvert MFTravelMode:dict[@"mode"] fallback:params.mode];
|
|
81
|
+
params.waypoints = [NParamConvert MFLocationComponentArray:dict[@"waypoints"]];
|
|
82
|
+
params.language = [NParamConvert MFLanguageResult:dict[@"language"] fallback:params.language];
|
|
83
|
+
params.weighting = [NParamConvert MFRouteWeighting:dict[@"weighting"] fallback:params.weighting];
|
|
84
|
+
params.restriction = [NParamConvert MFRouteRestriction:dict[@"restriction"]];
|
|
85
85
|
|
|
86
86
|
return params;
|
|
87
87
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// NParamConvert.h
|
|
3
3
|
// react-native-map4d-services
|
|
4
4
|
//
|
|
5
5
|
// Created by Huy Dang on 26/01/2022.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
#ifndef
|
|
9
|
-
#define
|
|
8
|
+
#ifndef NParamConvert_h
|
|
9
|
+
#define NParamConvert_h
|
|
10
10
|
|
|
11
11
|
#import <Map4dServices/Map4dServices.h>
|
|
12
12
|
|
|
13
|
-
@interface
|
|
13
|
+
@interface NParamConvert : NSObject
|
|
14
14
|
|
|
15
15
|
+ (BOOL)BOOL:(id)json fallback:(BOOL)fallback;
|
|
16
16
|
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
@end
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
#endif /*
|
|
44
|
+
#endif /* NParamConvert_h */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// NParamConvert.m
|
|
3
3
|
// react-native-map4d-services
|
|
4
4
|
//
|
|
5
5
|
// Created by Huy Dang on 26/01/2022.
|
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
#import <React/RCTConvert.h>
|
|
9
9
|
#import <React/RCTConvert+CoreLocation.h>
|
|
10
|
-
#import "
|
|
10
|
+
#import "NParamConvert.h"
|
|
11
11
|
|
|
12
|
-
@interface
|
|
12
|
+
@interface NParamConvert (Private)
|
|
13
13
|
+ (BOOL)isNull:(id)json;
|
|
14
14
|
+ (BOOL)isMFRouteType:(NSString *)type;
|
|
15
15
|
+ (MFRouteType)MFRouteType:(NSString *)type;
|
|
16
16
|
@end
|
|
17
17
|
|
|
18
|
-
#pragma mark -
|
|
18
|
+
#pragma mark - NParamConvert
|
|
19
19
|
|
|
20
|
-
@implementation
|
|
20
|
+
@implementation NParamConvert
|
|
21
21
|
|
|
22
22
|
+ (BOOL)BOOL:(id)json fallback:(BOOL)fallback {
|
|
23
23
|
return [self isNull:json] ? fallback : [RCTConvert BOOL:json];
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
return nil;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
MFLocationComponent *southwest = [
|
|
86
|
-
MFLocationComponent *northeast = [
|
|
85
|
+
MFLocationComponent *southwest = [NParamConvert MFLocationComponent:json[@"southwest"]];
|
|
86
|
+
MFLocationComponent *northeast = [NParamConvert MFLocationComponent:json[@"northeast"]];
|
|
87
87
|
return [[MFViewboxComponent alloc] initWithSouthwest:southwest.coordinate northeast:northeast.coordinate];
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
return nil;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
MFLocationComponent *location = [
|
|
95
|
+
MFLocationComponent *location = [NParamConvert MFLocationComponent:json[@"location"]];
|
|
96
96
|
NSUInteger radius = json[@"radius"] != nil ? [RCTConvert NSUInteger:json[@"radius"]] : 0;
|
|
97
|
-
MFViewboxComponent *viewbox = [
|
|
98
|
-
NSArray<MFLocationComponent *> *path = [
|
|
97
|
+
MFViewboxComponent *viewbox = [NParamConvert MFViewboxComponent:json[@"viewbox"]];
|
|
98
|
+
NSArray<MFLocationComponent *> *path = [NParamConvert MFLocationComponentArray:json[@"path"]];
|
|
99
99
|
NSArray<NSString *> *types = [RCTConvert NSStringArray:json[@"types"]];
|
|
100
100
|
|
|
101
101
|
MFRouteRestriction *result = nil;
|
|
@@ -112,16 +112,16 @@
|
|
|
112
112
|
if (types != nil && types.count > 0) {
|
|
113
113
|
if (result != nil) {
|
|
114
114
|
for (NSUInteger i = 0; i < types.count; i++) {
|
|
115
|
-
if ([
|
|
116
|
-
[result avoidRouteType:[
|
|
115
|
+
if ([NParamConvert isMFRouteType:types[i]]) {
|
|
116
|
+
[result avoidRouteType:[NParamConvert MFRouteType:types[i]]];
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
|
-
result = [[MFRouteRestriction alloc] initWithRouteType:[
|
|
121
|
+
result = [[MFRouteRestriction alloc] initWithRouteType:[NParamConvert MFRouteType:types[0]]];
|
|
122
122
|
for (NSUInteger i = 1; i < types.count; i++) {
|
|
123
|
-
if ([
|
|
124
|
-
[result avoidRouteType:[
|
|
123
|
+
if ([NParamConvert isMFRouteType:types[i]]) {
|
|
124
|
+
[result avoidRouteType:[NParamConvert MFRouteType:types[i]]];
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -184,10 +184,10 @@
|
|
|
184
184
|
|
|
185
185
|
@end
|
|
186
186
|
|
|
187
|
-
#pragma mark -
|
|
187
|
+
#pragma mark - NParamConvert (Private)
|
|
188
188
|
|
|
189
189
|
|
|
190
|
-
@implementation
|
|
190
|
+
@implementation NParamConvert (Private)
|
|
191
191
|
|
|
192
192
|
+ (BOOL)isNull:(id)json {
|
|
193
193
|
if (json == nil || [json isKindOfClass:[NSNull class]]) {
|