react-native-map4d-services 1.0.2 → 1.2.0
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/LICENSE +21 -21
- package/README.md +24 -24
- package/android/build.gradle +58 -60
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesModule.java +78 -91
- package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesPackage.java +28 -28
- package/android/src/main/java/com/reactnativemap4dservices/SClient.java +50 -50
- package/android/src/main/java/com/reactnativemap4dservices/SConverter.java +166 -166
- package/android/src/main/java/com/reactnativemap4dservices/SJsonUtils.java +130 -130
- package/android/src/main/java/com/reactnativemap4dservices/SRequest.java +280 -376
- package/ios/Map4dServices.h +5 -5
- package/ios/Map4dServices.m +67 -81
- package/ios/Map4dServices.xcodeproj/project.pbxproj +2 -2
- package/ios/SClient.h +23 -23
- package/ios/SClient.m +47 -47
- package/ios/SParamConvert.h +44 -44
- package/ios/SParamConvert.m +229 -229
- package/ios/SRequest.h +36 -40
- package/ios/SRequest.m +112 -142
- package/lib/commonjs/index.js +21 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +22 -14
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +217 -111
- package/package.json +151 -150
- package/react-native-map4d-services.podspec +27 -20
- package/src/index.tsx +268 -175
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "react-native-map4d-services"
|
|
7
|
-
s.version = package["version"]
|
|
8
|
-
s.summary = package["description"]
|
|
9
|
-
s.homepage = package["homepage"]
|
|
10
|
-
s.license = package["license"]
|
|
11
|
-
s.authors = package["author"]
|
|
12
|
-
|
|
13
|
-
s.platforms = { :ios => "
|
|
14
|
-
s.source = { :git => "https://github.com/map4d/map4d-services-react-native.git", :tag => "#{s.version}" }
|
|
15
|
-
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
|
-
|
|
18
|
-
s.dependency "
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-map4d-services"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "12.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/map4d/map4d-services-react-native.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
|
+
|
|
18
|
+
s.dependency "Map4dServices", "~> 2.5"
|
|
19
|
+
|
|
20
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
22
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
else
|
|
25
|
+
s.dependency "React-Core"
|
|
26
|
+
end
|
|
27
|
+
end
|
package/src/index.tsx
CHANGED
|
@@ -1,175 +1,268 @@
|
|
|
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
|
|
112
|
-
origins: MFLocationComponent[],
|
|
113
|
-
|
|
114
|
-
mode?: MFTravelMode | string,
|
|
115
|
-
weighting?: MFRouteWeighting | string,
|
|
116
|
-
language?: MFLanguageResult | string,
|
|
117
|
-
restriction?: MFRouteRestriction,
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
export
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
export
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
export function
|
|
162
|
-
return Map4dServices.
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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?: 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 MFDistanceMatrixParams = {
|
|
112
|
+
origins: MFLocationComponent[],
|
|
113
|
+
destinations: MFLocationComponent[],
|
|
114
|
+
mode?: MFTravelMode | string,
|
|
115
|
+
weighting?: MFRouteWeighting | string,
|
|
116
|
+
language?: MFLanguageResult | string,
|
|
117
|
+
restriction?: MFRouteRestriction,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
type MFServiceResponse<T> = {
|
|
121
|
+
code: string,
|
|
122
|
+
message?: string,
|
|
123
|
+
result?: T
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Place | Suggestions */
|
|
127
|
+
|
|
128
|
+
export type MFSuggestionResult = Array<{
|
|
129
|
+
id?: string
|
|
130
|
+
name?: string
|
|
131
|
+
address?: string
|
|
132
|
+
distance?: number
|
|
133
|
+
location?: { lat: number, lng: number }
|
|
134
|
+
types?: string[]
|
|
135
|
+
[_: string]: unknown
|
|
136
|
+
}>
|
|
137
|
+
export type MFSuggestionResponse = MFServiceResponse<MFSuggestionResult>
|
|
138
|
+
|
|
139
|
+
export async function fetchSuggestion(params: MFSuggestionParams): Promise<MFSuggestionResponse> {
|
|
140
|
+
return Map4dServices.fetchSuggestion(params);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Place | Detail */
|
|
144
|
+
|
|
145
|
+
export type MFPlaceDetailResult = {
|
|
146
|
+
id?: string
|
|
147
|
+
name?: string
|
|
148
|
+
description?: string
|
|
149
|
+
address?: string
|
|
150
|
+
addressComponents?: Array<any>
|
|
151
|
+
distance?: number
|
|
152
|
+
location?: { lat: number, lng: number }
|
|
153
|
+
types?: string[]
|
|
154
|
+
tags?: string[]
|
|
155
|
+
photos?: Array<any>
|
|
156
|
+
metadata?: Array<any>
|
|
157
|
+
[_: string]: unknown
|
|
158
|
+
}
|
|
159
|
+
export type MFPlaceDetailResponse = MFServiceResponse<MFPlaceDetailResult>
|
|
160
|
+
|
|
161
|
+
export async function fetchPlaceDetail(placeId: string): Promise<MFPlaceDetailResponse> {
|
|
162
|
+
return Map4dServices.fetchPlaceDetail(placeId);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Place | Text search */
|
|
166
|
+
|
|
167
|
+
export type MFTextSearchResult = Array<{
|
|
168
|
+
id?: string
|
|
169
|
+
name?: string
|
|
170
|
+
address?: string
|
|
171
|
+
distance?: number
|
|
172
|
+
location?: { lat: number, lng: number }
|
|
173
|
+
types?: string[]
|
|
174
|
+
[_: string]: unknown
|
|
175
|
+
}>
|
|
176
|
+
export type MFTextSearchResponse = MFServiceResponse<MFTextSearchResult>
|
|
177
|
+
|
|
178
|
+
export async function fetchTextSearch(params: MFTextSearchParams): Promise<MFTextSearchResponse> {
|
|
179
|
+
return Map4dServices.fetchTextSearch(params);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Place | Nearby search */
|
|
183
|
+
|
|
184
|
+
export type MFNearbySearchResult = Array<{
|
|
185
|
+
id?: string
|
|
186
|
+
name?: string
|
|
187
|
+
address?: string
|
|
188
|
+
distance?: number
|
|
189
|
+
location?: { lat: number, lng: number }
|
|
190
|
+
types?: string[]
|
|
191
|
+
[_: string]: unknown
|
|
192
|
+
}>
|
|
193
|
+
export type MFNearbySearchResponse = MFServiceResponse<MFNearbySearchResult>
|
|
194
|
+
|
|
195
|
+
export async function fetchNearbySearch(params: MFNearbySearchParams): Promise<MFNearbySearchResponse> {
|
|
196
|
+
return Map4dServices.fetchNearbySearch(params);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Place | Viewbox search */
|
|
200
|
+
|
|
201
|
+
export type MFViewboxSearchResult = Array<{
|
|
202
|
+
id?: string
|
|
203
|
+
name?: string
|
|
204
|
+
address?: string
|
|
205
|
+
distance?: number
|
|
206
|
+
location?: { lat: number, lng: number }
|
|
207
|
+
types?: string[]
|
|
208
|
+
[_: string]: unknown
|
|
209
|
+
}>
|
|
210
|
+
export type MFViewboxSearchResponse = MFServiceResponse<MFViewboxSearchResult>
|
|
211
|
+
|
|
212
|
+
export async function fetchViewboxSearch(params: MFViewboxSearchParams): Promise<MFViewboxSearchResponse> {
|
|
213
|
+
return Map4dServices.fetchViewboxSearch(params);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Place | Geocode */
|
|
217
|
+
|
|
218
|
+
export type MFGeocodeResult = Array<{
|
|
219
|
+
id?: string
|
|
220
|
+
name?: string
|
|
221
|
+
address?: string
|
|
222
|
+
distance?: number
|
|
223
|
+
location?: { lat: number, lng: number }
|
|
224
|
+
types?: string[]
|
|
225
|
+
addressComponents?: Array<any>
|
|
226
|
+
[_: string]: unknown
|
|
227
|
+
}>
|
|
228
|
+
export type MFGeocodeResponse = MFServiceResponse<MFGeocodeResult>
|
|
229
|
+
|
|
230
|
+
export async function fetchGeocode(params: MFGeocodeParams): Promise<MFGeocodeResponse> {
|
|
231
|
+
return Map4dServices.fetchGeocode(params);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Route | Directions */
|
|
235
|
+
|
|
236
|
+
export type MFDirectionsResult = {
|
|
237
|
+
routes?: Array<{
|
|
238
|
+
summary?: string
|
|
239
|
+
overviewPolyline?: string
|
|
240
|
+
distance?: { [key: string]: any }
|
|
241
|
+
duration?: { [key: string]: any }
|
|
242
|
+
legs?: Array<{ [key: string]: any }>
|
|
243
|
+
snappedWaypoints?: Array<{ lat: number, lng: number }>
|
|
244
|
+
[_: string]: unknown
|
|
245
|
+
}>
|
|
246
|
+
[_: string]: unknown
|
|
247
|
+
}
|
|
248
|
+
export type MFDirectionsResponse = MFServiceResponse<MFDirectionsResult>
|
|
249
|
+
|
|
250
|
+
export async function fetchDirections(params: MFDirectionsParams): Promise<MFDirectionsResponse> {
|
|
251
|
+
return Map4dServices.fetchDirections(params);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* Route | Distance matrix */
|
|
255
|
+
|
|
256
|
+
export type MFDistanceMatrixResult = {
|
|
257
|
+
originAddresses?: string[],
|
|
258
|
+
destinationAddresses?: string[],
|
|
259
|
+
routeRows: Array<{
|
|
260
|
+
elements: Array<{ [key:string]: any }>
|
|
261
|
+
}>
|
|
262
|
+
[_: string]: unknown
|
|
263
|
+
}
|
|
264
|
+
export type MFDistanceMatrixResponse = MFServiceResponse<MFDistanceMatrixResult>
|
|
265
|
+
|
|
266
|
+
export async function fetchDistanceMatrix(params: MFDistanceMatrixParams): Promise<MFDistanceMatrixResponse> {
|
|
267
|
+
return Map4dServices.fetchDistanceMatrix(params);
|
|
268
|
+
}
|