react-native-map-link 3.0.2 → 3.1.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 +30 -6
- package/lib/components/popup/Popup.d.ts +2 -2
- package/lib/components/popup/Popup.js +2 -1
- package/lib/constants.js +3 -0
- package/lib/images/sygic.png +0 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +16 -1
- package/package.json +3 -3
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
|
|
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
|
-
##
|
|
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: {
|
|
240
|
-
app: 'uber',
|
|
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
|
|
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
|
|
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Popup = void 0;
|
|
29
30
|
const react_1 = __importStar(require("react"));
|
|
30
31
|
const react_native_1 = require("react-native");
|
|
31
32
|
const utils_1 = require("../../utils");
|
|
@@ -82,6 +83,7 @@ const Popup = ({ isVisible, showHeader = true, customHeader, customFooter, onApp
|
|
|
82
83
|
</react_native_1.View>
|
|
83
84
|
</react_native_1.Modal>);
|
|
84
85
|
};
|
|
86
|
+
exports.Popup = Popup;
|
|
85
87
|
const styles = react_native_1.StyleSheet.create({
|
|
86
88
|
container: {
|
|
87
89
|
backgroundColor: 'white',
|
|
@@ -107,4 +109,3 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
107
109
|
elevation: 5,
|
|
108
110
|
},
|
|
109
111
|
});
|
|
110
|
-
exports.default = Popup;
|
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/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GetAppsProps, GetAppsResponse, ShowLocationProps } from './type';
|
|
2
2
|
export type { DirectionMode, GetAppsProps, GetAppsResponse, MapId, MapLinkOptions, PopupProps, PopupStyleProp, SharedOptions, ShowLocationProps, } from './type';
|
|
3
|
+
export { Popup } from './components/popup/Popup';
|
|
3
4
|
export declare const showLocation: ({ latitude, longitude, sourceLatitude, sourceLongitude, appleIgnoreLatLon, alwaysIncludeGoogle, googleForceLatLon, googlePlaceId, title: customTitle, app: customApp, dialogTitle: customDialogTitle, dialogMessage: customDialogMessage, cancelText: customCancelText, appsWhiteList: customAppsWhiteList, appTitles, naverCallerName, directionsMode, }: ShowLocationProps) => Promise<string | null | undefined>;
|
|
4
5
|
export declare function getApps({ alwaysIncludeGoogle, appsWhiteList, appTitles, naverCallerName, ...rest }: GetAppsProps): Promise<GetAppsResponse[]>;
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getApps = exports.showLocation = void 0;
|
|
3
|
+
exports.getApps = exports.showLocation = exports.Popup = void 0;
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
+
var Popup_1 = require("./components/popup/Popup");
|
|
8
|
+
Object.defineProperty(exports, "Popup", { enumerable: true, get: function () { return Popup_1.Popup; } });
|
|
7
9
|
const showLocation = async ({ latitude, longitude, sourceLatitude, sourceLongitude, appleIgnoreLatLon, alwaysIncludeGoogle, googleForceLatLon, googlePlaceId, title: customTitle, app: customApp, dialogTitle: customDialogTitle, dialogMessage: customDialogMessage, cancelText: customCancelText, appsWhiteList: customAppsWhiteList, appTitles, naverCallerName, directionsMode, }) => {
|
|
8
10
|
const prefixes = (0, constants_1.generatePrefixes)({
|
|
9
11
|
alwaysIncludeGoogle,
|
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
|
+
"version": "3.1.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",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"jest": "^29.7.0",
|
|
61
61
|
"metro-react-native-babel-preset": "^0.77.0",
|
|
62
62
|
"prettier": "^3.2.5",
|
|
63
|
+
"react": "^18.2.0",
|
|
63
64
|
"react-native": "^0.73.4",
|
|
64
65
|
"react-native-typescript-transformer": "^1.2.13",
|
|
65
66
|
"semantic-release": "^23.0.2",
|
|
@@ -74,8 +75,7 @@
|
|
|
74
75
|
"js"
|
|
75
76
|
],
|
|
76
77
|
"transform": {
|
|
77
|
-
"^.+\\.(js)$": "<rootDir>/node_modules/babel-jest"
|
|
78
|
-
"\\.(ts|tsx)$": "ts-jest"
|
|
78
|
+
"^.+\\.(js|ts|tsx)$": "<rootDir>/node_modules/babel-jest"
|
|
79
79
|
},
|
|
80
80
|
"setupFiles": [
|
|
81
81
|
"./tests/setup.ts"
|