react-native-map4d-services 0.1.0 → 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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -24
  3. package/android/build.gradle +60 -59
  4. package/android/src/main/AndroidManifest.xml +4 -4
  5. package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesModule.java +91 -34
  6. package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesPackage.java +28 -28
  7. package/android/src/main/java/com/reactnativemap4dservices/SClient.java +50 -0
  8. package/android/src/main/java/com/reactnativemap4dservices/SConverter.java +166 -0
  9. package/android/src/main/java/com/reactnativemap4dservices/SJsonUtils.java +130 -0
  10. package/android/src/main/java/com/reactnativemap4dservices/SRequest.java +376 -0
  11. package/ios/Map4dServices.h +5 -5
  12. package/ios/Map4dServices.m +81 -81
  13. package/ios/SClient.h +23 -23
  14. package/ios/SClient.m +47 -47
  15. package/ios/SParamConvert.h +44 -0
  16. package/ios/SParamConvert.m +229 -0
  17. package/ios/SRequest.h +40 -40
  18. package/ios/SRequest.m +142 -143
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/typescript/index.d.ts +111 -111
  22. package/package.json +150 -150
  23. package/react-native-map4d-services.podspec +20 -20
  24. package/src/index.tsx +174 -174
  25. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  26. package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
  27. package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
  28. package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
  29. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  30. package/android/.gradle/7.1.1/gc.properties +0 -0
  31. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  32. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  33. package/android/.gradle/checksums/checksums.lock +0 -0
  34. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  35. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  36. package/android/.gradle/vcs-1/gc.properties +0 -0
  37. package/ios/.DS_Store +0 -0
  38. package/ios/Map4dServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
  39. package/ios/RCTConvert+Services.h +0 -33
  40. package/ios/RCTConvert+Services.m +0 -146
package/src/index.tsx CHANGED
@@ -1,175 +1,175 @@
1
- import { NativeModules, Platform } from 'react-native';
2
-
3
- const LINKING_ERROR =
4
- `The package 'react-native-map4d-services' doesn't seem to be linked. Make sure: \n\n` +
5
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
- '- You rebuilt the app after installing the package\n' +
7
- '- You are not using Expo managed workflow\n';
8
-
9
- const Map4dServices = NativeModules.Map4dServices
10
- ? NativeModules.Map4dServices
11
- : new Proxy(
12
- {},
13
- {
14
- get() {
15
- throw new Error(LINKING_ERROR);
16
- },
17
- }
18
- );
19
-
20
- export type MFLocationComponent = {
21
- latitude: number,
22
- longitude: number,
23
- alias?: string,
24
- }
25
-
26
- export type MFViewboxComponent = {
27
- southwest: MFLocationComponent,
28
- northeast: MFLocationComponent,
29
- }
30
-
31
- export enum MFTravelMode {
32
- car = 'car',
33
- bike = 'bike',
34
- foot = 'foot',
35
- motorcycle = 'motorcycle',
36
- }
37
-
38
- export enum MFRouteWeighting {
39
- shortest = 'shortest',
40
- fastest = 'fastest',
41
- balance = 'balance',
42
- }
43
-
44
- export enum MFLanguageResult {
45
- en = 'en',
46
- vi = 'vi',
47
- }
48
-
49
- export enum MFRouteType {
50
- motorway = 'motorway',
51
- trunk = 'trunk',
52
- ferry = 'ferry',
53
- bridge = 'bridge',
54
- tunnel = 'tunnel',
55
- }
56
-
57
- export type MFRouteRestriction = {
58
- location?: MFLocationComponent,
59
- radius?: number,
60
- viewbox?: MFViewboxComponent,
61
- path?: MFLocationComponent[],
62
- types?: MFRouteType[] | string[]
63
- }
64
-
65
- export type MFSuggestionParams = {
66
- text: string,
67
- location?: MFLocationComponent,
68
- acronym?: boolean,
69
- }
70
-
71
- export type MFTextSearchParams = {
72
- text: string,
73
- types?: string[],
74
- datetime?: Date,
75
- location?: MFLocationComponent,
76
- }
77
-
78
- export type MFNearbySearchParams = {
79
- location: MFLocationComponent,
80
- radius: number,
81
- text?: string,
82
- types?: string[],
83
- tags?: string[],
84
- datetime?: Date,
85
- }
86
-
87
- export type MFViewboxSearchParams = {
88
- viewbox: MFViewboxComponent,
89
- text?: string,
90
- types?: string[],
91
- tags?: string[],
92
- datetime?: Date,
93
- }
94
-
95
- export type MFGeocodeParams = {
96
- location?: MFLocationComponent,
97
- address?: string,
98
- viewbox?: MFViewboxComponent,
99
- }
100
-
101
- export type MFDirectionsParams = {
102
- origin: MFLocationComponent,
103
- destination: MFLocationComponent,
104
- waypoints?: MFLocationComponent[],
105
- mode?: MFTravelMode | string,
106
- weighting?: MFRouteWeighting | string,
107
- language?: MFLanguageResult | string,
108
- restriction?: MFRouteRestriction,
109
- }
110
-
111
- export type MFRouteETAParams = {
112
- origins: MFLocationComponent[],
113
- destination: MFLocationComponent,
114
- mode?: MFTravelMode | string,
115
- weighting?: MFRouteWeighting | string,
116
- language?: MFLanguageResult | string,
117
- restriction?: MFRouteRestriction,
118
- }
119
-
120
- export type MFDistanceMatrixParams = {
121
- origins: MFLocationComponent[],
122
- destinations: MFLocationComponent[],
123
- mode?: MFTravelMode | string,
124
- weighting?: MFRouteWeighting | string,
125
- language?: MFLanguageResult | string,
126
- restriction?: MFRouteRestriction,
127
- }
128
-
129
- export type MFGraphRouteParams = {
130
- locations: MFLocationComponent[],
131
- mode?: MFTravelMode | string,
132
- weighting?: MFRouteWeighting | string,
133
- language?: MFLanguageResult | string,
134
- restriction?: MFRouteRestriction,
135
- }
136
-
137
- export function fetchSuggestion(params: MFSuggestionParams): Promise<object> {
138
- return Map4dServices.fetchSuggestion(params);
139
- }
140
-
141
- export function fetchPlaceDetail(placeId: string): Promise<object> {
142
- return Map4dServices.fetchPlaceDetail(placeId);
143
- }
144
-
145
- export function fetchTextSearch(params: MFTextSearchParams): Promise<object> {
146
- return Map4dServices.fetchTextSearch(params);
147
- }
148
-
149
- export function fetchNearbySearch(params: MFNearbySearchParams): Promise<object> {
150
- return Map4dServices.fetchNearbySearch(params);
151
- }
152
-
153
- export function fetchViewboxSearch(params: MFViewboxSearchParams): Promise<object> {
154
- return Map4dServices.fetchViewboxSearch(params);
155
- }
156
-
157
- export function fetchGeocode(params: MFGeocodeParams): Promise<object> {
158
- return Map4dServices.fetchGeocode(params);
159
- }
160
-
161
- export function fetchDirections(params: MFDirectionsParams): Promise<object> {
162
- return Map4dServices.fetchDirections(params);
163
- }
164
-
165
- export function fetchRouteETA(params: MFRouteETAParams): Promise<object> {
166
- return Map4dServices.fetchRouteETA(params);
167
- }
168
-
169
- export function fetchDistanceMatrix(params: MFDistanceMatrixParams): Promise<object> {
170
- return Map4dServices.fetchDistanceMatrix(params);
171
- }
172
-
173
- export function fetchGraphRoute(params: MFGraphRouteParams): Promise<object> {
174
- return Map4dServices.fetchGraphRoute(params);
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'react-native-map4d-services' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo managed workflow\n';
8
+
9
+ const Map4dServices = NativeModules.Map4dServices
10
+ ? NativeModules.Map4dServices
11
+ : new Proxy(
12
+ {},
13
+ {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ },
17
+ }
18
+ );
19
+
20
+ export type MFLocationComponent = {
21
+ latitude: number,
22
+ longitude: number,
23
+ alias?: string,
24
+ }
25
+
26
+ export type MFViewboxComponent = {
27
+ southwest: MFLocationComponent,
28
+ northeast: MFLocationComponent,
29
+ }
30
+
31
+ export enum MFTravelMode {
32
+ car = 'car',
33
+ bike = 'bike',
34
+ foot = 'foot',
35
+ motorcycle = 'motorcycle',
36
+ }
37
+
38
+ export enum MFRouteWeighting {
39
+ shortest = 'shortest',
40
+ fastest = 'fastest',
41
+ balance = 'balance',
42
+ }
43
+
44
+ export enum MFLanguageResult {
45
+ en = 'en',
46
+ vi = 'vi',
47
+ }
48
+
49
+ export enum MFRouteType {
50
+ motorway = 'motorway',
51
+ trunk = 'trunk',
52
+ ferry = 'ferry',
53
+ bridge = 'bridge',
54
+ tunnel = 'tunnel',
55
+ }
56
+
57
+ export type MFRouteRestriction = {
58
+ location?: MFLocationComponent,
59
+ radius?: number,
60
+ viewbox?: MFViewboxComponent,
61
+ path?: MFLocationComponent[],
62
+ types?: MFRouteType[] | string[]
63
+ }
64
+
65
+ export type MFSuggestionParams = {
66
+ text: string,
67
+ location?: MFLocationComponent,
68
+ acronym?: boolean,
69
+ }
70
+
71
+ export type MFTextSearchParams = {
72
+ text: string,
73
+ types?: string[],
74
+ datetime?: number,
75
+ location?: MFLocationComponent,
76
+ }
77
+
78
+ export type MFNearbySearchParams = {
79
+ location: MFLocationComponent,
80
+ radius: number,
81
+ text?: string,
82
+ types?: string[],
83
+ tags?: string[],
84
+ datetime?: number,
85
+ }
86
+
87
+ export type MFViewboxSearchParams = {
88
+ viewbox: MFViewboxComponent,
89
+ text?: string,
90
+ types?: string[],
91
+ tags?: string[],
92
+ datetime?: number,
93
+ }
94
+
95
+ export type MFGeocodeParams = {
96
+ location?: MFLocationComponent,
97
+ address?: string,
98
+ viewbox?: MFViewboxComponent,
99
+ }
100
+
101
+ export type MFDirectionsParams = {
102
+ origin: MFLocationComponent,
103
+ destination: MFLocationComponent,
104
+ waypoints?: MFLocationComponent[],
105
+ mode?: MFTravelMode | string,
106
+ weighting?: MFRouteWeighting | string,
107
+ language?: MFLanguageResult | string,
108
+ restriction?: MFRouteRestriction,
109
+ }
110
+
111
+ export type MFRouteETAParams = {
112
+ origins: MFLocationComponent[],
113
+ destination: MFLocationComponent,
114
+ mode?: MFTravelMode | string,
115
+ weighting?: MFRouteWeighting | string,
116
+ language?: MFLanguageResult | string,
117
+ restriction?: MFRouteRestriction,
118
+ }
119
+
120
+ export type MFDistanceMatrixParams = {
121
+ origins: MFLocationComponent[],
122
+ destinations: MFLocationComponent[],
123
+ mode?: MFTravelMode | string,
124
+ weighting?: MFRouteWeighting | string,
125
+ language?: MFLanguageResult | string,
126
+ restriction?: MFRouteRestriction,
127
+ }
128
+
129
+ export type MFGraphRouteParams = {
130
+ locations: MFLocationComponent[],
131
+ mode?: MFTravelMode | string,
132
+ weighting?: MFRouteWeighting | string,
133
+ language?: MFLanguageResult | string,
134
+ restriction?: MFRouteRestriction,
135
+ }
136
+
137
+ export function fetchSuggestion(params: MFSuggestionParams): Promise<any> {
138
+ return Map4dServices.fetchSuggestion(params);
139
+ }
140
+
141
+ export function fetchPlaceDetail(placeId: string): Promise<any> {
142
+ return Map4dServices.fetchPlaceDetail(placeId);
143
+ }
144
+
145
+ export function fetchTextSearch(params: MFTextSearchParams): Promise<any> {
146
+ return Map4dServices.fetchTextSearch(params);
147
+ }
148
+
149
+ export function fetchNearbySearch(params: MFNearbySearchParams): Promise<any> {
150
+ return Map4dServices.fetchNearbySearch(params);
151
+ }
152
+
153
+ export function fetchViewboxSearch(params: MFViewboxSearchParams): Promise<any> {
154
+ return Map4dServices.fetchViewboxSearch(params);
155
+ }
156
+
157
+ export function fetchGeocode(params: MFGeocodeParams): Promise<any> {
158
+ return Map4dServices.fetchGeocode(params);
159
+ }
160
+
161
+ export function fetchDirections(params: MFDirectionsParams): Promise<any> {
162
+ return Map4dServices.fetchDirections(params);
163
+ }
164
+
165
+ export function fetchRouteETA(params: MFRouteETAParams): Promise<any> {
166
+ return Map4dServices.fetchRouteETA(params);
167
+ }
168
+
169
+ export function fetchDistanceMatrix(params: MFDistanceMatrixParams): Promise<any> {
170
+ return Map4dServices.fetchDistanceMatrix(params);
171
+ }
172
+
173
+ export function fetchGraphRoute(params: MFGraphRouteParams): Promise<any> {
174
+ return Map4dServices.fetchGraphRoute(params);
175
175
  }
File without changes
@@ -1,2 +0,0 @@
1
- #Wed Feb 09 14:52:11 ICT 2022
2
- gradle.version=7.1.1
File without changes
package/ios/.DS_Store DELETED
Binary file
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- </Workspace>
@@ -1,33 +0,0 @@
1
- //
2
- // RCTConvert+Services.h
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #ifndef RCTConvert_Services_h
9
- #define RCTConvert_Services_h
10
-
11
- #import <React/RCTConvert.h>
12
- #import <Map4dServices/Map4dServices.h>
13
-
14
- @interface RCTConvert (Services)
15
-
16
- + (MFLocationComponent *)MFLocationComponent:(id)json;
17
-
18
- + (NSArray<MFLocationComponent *> *)MFLocationComponentArray:(id)json;
19
-
20
- + (MFViewboxComponent *)MFViewboxComponent:(id)json;
21
-
22
- + (MFRouteRestriction *)MFRouteRestriction:(id)json;
23
-
24
- + (MFTravelMode)MFTravelMode:(id)json;
25
-
26
- + (MFRouteWeighting)MFRouteWeighting:(id)json;
27
-
28
- + (MFLanguageResult)MFLanguageResult:(id)json;
29
-
30
- @end
31
-
32
-
33
- #endif /* RCTConvert_Services_h */
@@ -1,146 +0,0 @@
1
- //
2
- // RCTConvert+Services.m
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #import <React/RCTConvert+CoreLocation.h>
9
- #import "RCTConvert+Services.h"
10
-
11
- @implementation RCTConvert (Services)
12
-
13
- + (MFLocationComponent *)MFLocationComponent:(id)json {
14
- if (json == nil) {
15
- return nil;
16
- }
17
- CLLocationCoordinate2D coordinate = [RCTConvert CLLocationCoordinate2D:json];
18
- return [[MFLocationComponent alloc] initWithCoordinate:coordinate alias:json[@"alias"]];
19
- }
20
-
21
- RCT_ARRAY_CONVERTER(MFLocationComponent);
22
-
23
- + (MFViewboxComponent *)MFViewboxComponent:(id)json {
24
- if (json == nil) {
25
- return nil;
26
- }
27
-
28
- MFLocationComponent *southwest = [RCTConvert MFLocationComponent:json[@"southwest"]];
29
- MFLocationComponent *northeast = [RCTConvert MFLocationComponent:json[@"northeast"]];
30
- return [[MFViewboxComponent alloc] initWithSouthwest:southwest.coordinate northeast:northeast.coordinate];
31
- }
32
-
33
- + (MFRouteRestriction *)MFRouteRestriction:(id)json {
34
- if (json == nil) {
35
- return nil;
36
- }
37
-
38
- MFLocationComponent *location = [RCTConvert MFLocationComponent:json[@"location"]];
39
- NSUInteger radius = json[@"radius"] != nil ? [RCTConvert NSUInteger:json[@"radius"]] : 0;
40
- MFViewboxComponent *viewbox = [RCTConvert MFViewboxComponent:json[@"viewbox"]];
41
- NSArray<MFLocationComponent *> *path = [RCTConvert MFLocationComponentArray:json[@"path"]];
42
- NSArray<NSString *> *types = [RCTConvert NSStringArray:json[@"types"]];
43
-
44
- MFRouteRestriction *result = nil;
45
- if (location != nil) {
46
- result = [[MFRouteRestriction alloc] initWithLocation:location radius:radius];
47
- }
48
- else if (viewbox != nil) {
49
- result = [[MFRouteRestriction alloc] initWithViewbox:viewbox];
50
- }
51
- else if (path != nil) {
52
- result = [[MFRouteRestriction alloc] initWithPath:path];
53
- }
54
-
55
- if (types != nil && types.count > 0) {
56
- if (result != nil) {
57
- for (NSUInteger i = 0; i < types.count; i++) {
58
- if ([RCTConvert isMFRouteType:types[i]]) {
59
- [result avoidRouteType:[RCTConvert MFRouteType:types[i]]];
60
- }
61
- }
62
- }
63
- else {
64
- result = [[MFRouteRestriction alloc] initWithRouteType:[RCTConvert MFRouteType:types[0]]];
65
- for (NSUInteger i = 1; i < types.count; i++) {
66
- if ([RCTConvert isMFRouteType:types[i]]) {
67
- [result avoidRouteType:[RCTConvert MFRouteType:types[i]]];
68
- }
69
- }
70
- }
71
- }
72
-
73
- return result;
74
-
75
- }
76
-
77
- + (MFTravelMode)MFTravelMode:(id)json {
78
- NSString *mode = [RCTConvert NSString:json];
79
- if ([@"motorcycle" isEqualToString:mode]) {
80
- return MFTravelModeMotorcycle;
81
- }
82
- else if ([@"foot" isEqualToString:mode]) {
83
- return MFTravelModeFoot;
84
- }
85
- else if ([@"bike" isEqualToString:mode]) {
86
- return MFTravelModeBike;
87
- }
88
- else {
89
- return MFTravelModeCar;
90
- }
91
- }
92
-
93
- + (MFRouteWeighting)MFRouteWeighting:(id)json {
94
- NSString *weighting = [RCTConvert NSString:json];
95
- if ([@"shortest" isEqualToString:weighting]) {
96
- return MFRouteWeightingShortest;
97
- }
98
- else if ([@"balance" isEqualToString:weighting]) {
99
- return MFRouteWeightingBalance;
100
- }
101
- else {
102
- return MFRouteWeightingFastest;
103
- }
104
- }
105
-
106
- + (MFLanguageResult)MFLanguageResult:(id)json {
107
- NSString *language = [RCTConvert NSString:json];
108
- if ([@"en" isEqualToString:language]) {
109
- return MFLanguageResultEnglish;
110
- }
111
- else {
112
- return MFLanguageResultVietnamese;
113
- }
114
- }
115
-
116
- + (BOOL)isMFRouteType:(NSString *)type {
117
- if ([@"motorway" isEqualToString:type] ||
118
- [@"trunk" isEqualToString:type] ||
119
- [@"ferry" isEqualToString:type] ||
120
- [@"bridge" isEqualToString:type] ||
121
- [@"tunnel" isEqualToString:type]) {
122
- return YES;
123
- }
124
- return NO;
125
- }
126
-
127
- + (MFRouteType)MFRouteType:(NSString *)type {
128
- if ([@"motorway" isEqualToString:type]) {
129
- return MFRouteTypeMotorway;
130
- }
131
- else if ([@"trunk" isEqualToString:type]) {
132
- return MFRouteTypeTrunk;
133
- }
134
- else if ([@"ferry" isEqualToString:type]) {
135
- return MFRouteTypeFerry;
136
- }
137
- else if ([@"bridge" isEqualToString:type]) {
138
- return MFRouteTypeBridge;
139
- }
140
- else if ([@"tunnel" isEqualToString:type]) {
141
- return MFRouteTypeTunnel;
142
- }
143
- return 0;
144
- }
145
-
146
- @end