react-native-map-link 3.0.3 → 3.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/README.md CHANGED
@@ -10,7 +10,7 @@ An easy way to open a location in a map app of the user's choice, based on the a
10
10
  on their device. The app supports Apple Maps, Google Maps, Citymapper, Uber, and a dozen other apps.
11
11
 
12
12
  <details>
13
- <summary>Full list of supported apps</summary>
13
+ <summary><strong>Full list of supported apps</strong></summary>
14
14
 
15
15
  - Apple Maps – `apple-maps`
16
16
  - Google Maps – `google-maps`
@@ -34,15 +34,21 @@ on their device. The app supports Apple Maps, Google Maps, Citymapper, Uber, and
34
34
  - 2GIS - `dgis`
35
35
  - Liftago - `liftago`
36
36
  - Petal Maps - `petalmaps` (Android only)
37
+ - Sygic - `sygic`
37
38
 
38
39
  </details>
39
40
 
41
+ <br /><p align="center">
42
+ <img src="./docs/example.png" alt="Example screenshot" width="320" />
43
+
44
+ </p>
45
+
40
46
  ## Installation
41
47
 
42
48
  ### 1. Install the package
43
49
 
44
50
  ```shell
45
- npm i -S react-native-map-link # or yarn add react-native-map-link
51
+ npm i -S react-native-map-link # or yarn add react-native-map-link
46
52
  ```
47
53
 
48
54
  ### 2. Post-install steps
@@ -79,6 +85,7 @@ Just add this in your `Info.plist` depending on which apps you'd like to support
79
85
  <string>nmap</string>
80
86
  <string>dgis</string>
81
87
  <string>lftgpas</string>
88
+ <string>sygic</string>
82
89
  </array>
83
90
  ```
84
91
 
@@ -195,6 +202,10 @@ You can do so by coping the `<queries>` statement below, and pasting it in the t
195
202
  <action android:name="android.intent.action.VIEW" />
196
203
  <data android:scheme="petalmaps" />
197
204
  </intent>
205
+ <intent>
206
+ <action android:name="android.intent.action.VIEW" />
207
+ <data android:scheme="com.sygic.aura" />
208
+ </intent>
198
209
  </queries>
199
210
  ```
200
211
 
@@ -215,7 +226,19 @@ More info [here](https://stackoverflow.com/a/67383641/1129689).
215
226
 
216
227
  </details>
217
228
 
218
- ## Usage
229
+ ## Simple example
230
+
231
+ ```js
232
+ import {showLocation} from 'react-native-map-link';
233
+
234
+ showLocation({
235
+ latitude: 38.8976763,
236
+ longitude: -77.0387185,
237
+ title: 'Your destination',
238
+ });
239
+ ```
240
+
241
+ ## Full usage
219
242
 
220
243
  Using the `showLocation` function will shown an action sheet on iOS and an alert on Android, without any custom styling:
221
244
 
@@ -236,8 +259,8 @@ showLocation({
236
259
  cancelText: 'This is the cancel button text', // optional (default: 'Cancel')
237
260
  appsWhiteList: ['google-maps'], // optionally you can set which apps to show (default: will show all supported apps installed on device)
238
261
  naverCallerName: 'com.example.myapp', // to link into Naver Map You should provide your appname which is the bundle ID in iOS and applicationId in android.
239
- appTitles: { 'google-maps': 'My custom Google Maps title' }, // optionally you can override default app titles
240
- app: 'uber', // optionally specify specific app to use
262
+ appTitles: {'google-maps': 'My custom Google Maps title'}, // optionally you can override default app titles
263
+ app: 'uber', // optionally specify specific app to use
241
264
  directionsMode: 'walk', // optional, accepted values are 'car', 'walk', 'public-transport' or 'bike'
242
265
  });
243
266
  ```
@@ -245,8 +268,9 @@ showLocation({
245
268
  Notes:
246
269
 
247
270
  - The `sourceLatitude` / `sourceLongitude` options only work if you specify both. Currently supports all apps except Waze.
248
- - `directionsMode` works on google-maps and apple-maps (on the latter, `bike` mode will not work). Without setting it, the app will decide based on his own settings.
271
+ - `directionsMode` works on google-maps, apple-maps and sygic (on apple-maps, `bike` mode will not work, while on sygic, only `walk` and `car` will work). Without setting it, the app will decide based on its own settings.
249
272
  - If you set `directionsMode` but do not set `sourceLatitude` and `sourceLongitude`, google-maps and apple-maps will still enter directions mode, and use the current location as starting point.
273
+ -
250
274
 
251
275
  ### Or
252
276
 
@@ -0,0 +1,2 @@
1
+ declare const _exports: import('@expo/config-plugins').ConfigPlugin;
2
+ export = _exports;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
3
+ const { withAndroidManifest, withInfoPlist } = require('@expo/config-plugins');
4
+ const schemes = [
5
+ 'comgooglemaps',
6
+ 'citymapper',
7
+ 'uber',
8
+ 'lyft',
9
+ 'transit',
10
+ 'truckmap',
11
+ 'waze',
12
+ 'yandexnavi',
13
+ 'moovit',
14
+ 'yandextaxi',
15
+ 'yandexmaps',
16
+ 'kakaomap',
17
+ 'tmap',
18
+ 'szn-mapy',
19
+ 'mapsme',
20
+ 'osmandmaps',
21
+ 'gett',
22
+ 'nmap',
23
+ 'dgis',
24
+ 'lftgpas',
25
+ ];
26
+ const intents = ['geo', 'waze'].map((app) => {
27
+ return {
28
+ action: { $: { 'android:name': 'android.intent.action.VIEW' } },
29
+ data: { $: { 'android:scheme': app } },
30
+ };
31
+ });
32
+ /**
33
+ * @type {import('@expo/config-plugins').ConfigPlugin}
34
+ */
35
+ module.exports = function withReactNativeMapLink(config) {
36
+ // eslint-disable-next-line no-shadow
37
+ config = withAndroidManifest(config, async (config) => {
38
+ let intent = config.modResults.manifest.queries[0].intent ?? [];
39
+ // @ts-expect-error unnecessary type gymnastics
40
+ config.modResults.manifest.queries[0].intent = intent.concat(intents);
41
+ return config;
42
+ });
43
+ // eslint-disable-next-line no-shadow
44
+ return withInfoPlist(config, (config) => {
45
+ config.modResults.LSApplicationQueriesSchemes =
46
+ config.modResults.LSApplicationQueriesSchemes?.concat(schemes) ?? schemes;
47
+ return config;
48
+ });
49
+ };
package/lib/constants.js CHANGED
@@ -27,6 +27,7 @@ const generatePrefixes = ({ alwaysIncludeGoogle, naverCallerName, }) => {
27
27
  dgis: 'dgis://2gis.ru/',
28
28
  liftago: 'lftgpas://',
29
29
  petalmaps: 'petalmaps://',
30
+ sygic: 'com.sygic.aura://',
30
31
  };
31
32
  };
32
33
  exports.generatePrefixes = generatePrefixes;
@@ -60,6 +61,7 @@ const generateTitles = (titles) => {
60
61
  dgis: '2GIS',
61
62
  liftago: 'Liftago',
62
63
  petalmaps: 'Petal Maps',
64
+ sygic: 'Sygic',
63
65
  ...(titles || {}),
64
66
  };
65
67
  };
@@ -87,6 +89,7 @@ exports.icons = {
87
89
  dgis: require('./images/dgis.png'),
88
90
  liftago: require('./images/liftago.png'),
89
91
  petalmaps: require('./images/petalmaps.png'),
92
+ sygic: require('./images/sygic.png'),
90
93
  };
91
94
  exports.appKeys = Object.keys(exports.icons);
92
95
  exports.colorsPopup = {
Binary file
package/lib/utils.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare const askAppChoice: ({ dialogTitle, dialogMessage, cancelText, ap
13
13
  }) => Promise<string | null>;
14
14
  export declare const getDirectionsModeAppleMaps: (directionsMode: 'car' | 'walk' | 'public-transport' | 'bike' | undefined) => string | undefined;
15
15
  export declare const getDirectionsModeGoogleMaps: (directionsMode: 'car' | 'walk' | 'public-transport' | 'bike' | undefined) => string | undefined;
16
+ export declare const getDirectionsModeSygic: (directionsMode: 'car' | 'walk' | 'public-transport' | 'bike' | undefined) => string | undefined;
16
17
  export declare const checkOptions: ({ latitude, longitude, googleForceLatLon, googlePlaceId, title, app, prefixes, appTitles, appsWhiteList, }: {
17
18
  latitude: number | string;
18
19
  longitude: number | string;
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateMapUrl = exports.checkOptions = exports.getDirectionsModeGoogleMaps = exports.getDirectionsModeAppleMaps = exports.askAppChoice = exports.checkNotSupportedApps = exports.getNotSupportedApps = exports.isSupportedApp = exports.isAppInstalled = exports.getAvailableApps = void 0;
3
+ exports.generateMapUrl = exports.checkOptions = exports.getDirectionsModeSygic = exports.getDirectionsModeGoogleMaps = exports.getDirectionsModeAppleMaps = exports.askAppChoice = exports.checkNotSupportedApps = exports.getNotSupportedApps = exports.isSupportedApp = exports.isAppInstalled = exports.getAvailableApps = void 0;
4
4
  const react_native_1 = require("react-native");
5
5
  const constants_1 = require("./constants");
6
6
  const getAvailableApps = async (prefixes) => {
@@ -107,6 +107,16 @@ const getDirectionsModeGoogleMaps = (directionsMode) => {
107
107
  return modeMap[directionsMode || ''] || undefined;
108
108
  };
109
109
  exports.getDirectionsModeGoogleMaps = getDirectionsModeGoogleMaps;
110
+ const getDirectionsModeSygic = (directionsMode) => {
111
+ const modeMap = {
112
+ car: 'drive',
113
+ walk: 'walk',
114
+ 'public-transport': 'show',
115
+ bike: 'show',
116
+ };
117
+ return modeMap[directionsMode || ''] || undefined;
118
+ };
119
+ exports.getDirectionsModeSygic = getDirectionsModeSygic;
110
120
  const checkOptions = ({ latitude, longitude, googleForceLatLon, googlePlaceId, title, app, prefixes, appTitles, appsWhiteList, }) => {
111
121
  if (!latitude || !longitude) {
112
122
  throw new MapsException('`showLocation` should contain keys `latitude` and `longitude`.');
@@ -295,6 +305,11 @@ const generateMapUrl = ({ app, directionsMode, appleIgnoreLatLon, googleForceLat
295
305
  url += `&saddr=${sourceLat},${sourceLng}`;
296
306
  }
297
307
  break;
308
+ case 'sygic':
309
+ const sygicDirectionsMode = (0, exports.getDirectionsModeSygic)(directionsMode);
310
+ url = `${prefixes.sygic}coordinate|${lng}|${lat}|`;
311
+ url += sygicDirectionsMode ? `${sygicDirectionsMode}` : '';
312
+ break;
298
313
  }
299
314
  return url;
300
315
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-map-link",
3
- "version": "3.0.3",
3
+ "version": "3.2.0",
4
4
  "description": "Open the map app of the user's choice with a specific location.",
5
5
  "source": "src/index",
6
6
  "main": "lib/index.js",
@@ -44,6 +44,7 @@
44
44
  "@babel/eslint-parser": "^7.23.10",
45
45
  "@babel/eslint-plugin": "^7.23.5",
46
46
  "@babel/runtime": "^7.23.9",
47
+ "@expo/config-plugins": "^7.8.4",
47
48
  "@react-native-community/eslint-config": "^3.2.0",
48
49
  "@types/jest": "^29.5.12",
49
50
  "@types/react": "^18.2.55",
@@ -60,6 +61,7 @@
60
61
  "jest": "^29.7.0",
61
62
  "metro-react-native-babel-preset": "^0.77.0",
62
63
  "prettier": "^3.2.5",
64
+ "react": "^18.2.0",
63
65
  "react-native": "^0.73.4",
64
66
  "react-native-typescript-transformer": "^1.2.13",
65
67
  "semantic-release": "^23.0.2",
@@ -74,8 +76,7 @@
74
76
  "js"
75
77
  ],
76
78
  "transform": {
77
- "^.+\\.(js)$": "<rootDir>/node_modules/babel-jest",
78
- "\\.(ts|tsx)$": "ts-jest"
79
+ "^.+\\.(js|ts|tsx)$": "<rootDir>/node_modules/babel-jest"
79
80
  },
80
81
  "setupFiles": [
81
82
  "./tests/setup.ts"