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.
@@ -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 => "10.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 "React-Core"
19
- s.dependency "Map4dServices", "~> 2.0.0"
20
- end
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 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
- }
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
+ }