react-native-map-link 2.8.0 → 2.8.1

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 (3) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/src/index.js +27 -13
package/README.md CHANGED
@@ -224,9 +224,9 @@ showLocation({
224
224
  dialogMessage: 'This is the amazing dialog Message', // optional (default: 'What app would you like to use?')
225
225
  cancelText: 'This is the cancel button text', // optional (default: 'Cancel')
226
226
  appsWhiteList: ['google-maps'], // optionally you can set which apps to show (default: will show all supported apps installed on device)
227
- 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.
228
- // appTitles: { 'google-maps': 'My custom Google Maps title' } // optionally you can override default app titles
229
- // app: 'uber' // optionally specify specific app to use
227
+ 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.
228
+ // appTitles: { 'google-maps': 'My custom Google Maps title' }, // optionally you can override default app titles
229
+ // app: 'uber', // optionally specify specific app to use
230
230
  directionsMode: 'walk' // optional, accepted values are 'car', 'walk', 'public-transport' or 'bike'
231
231
  })
232
232
  ```
@@ -234,7 +234,7 @@ showLocation({
234
234
  Notes:
235
235
 
236
236
  - The `sourceLatitude/sourceLongitude` options only work if you specify both. Currently supports all apps except Waze.
237
- - Works on google-maps and apple-maps (on the latter, `bike` mode will not work). Without setting `directionsMode`, the app will decide based on his own settings.
237
+ - `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.
238
238
 
239
239
  ## More information
240
240
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-map-link",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "Open the map app of the user's choice with a specific location",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -17,7 +17,7 @@ import {askAppChoice, checkOptions} from './utils';
17
17
  * sourceLongitude: number | undefined | null,
18
18
  * alwaysIncludeGoogle: boolean | undefined | null,
19
19
  * googleForceLatLon: boolean | undefined | null,
20
- * googlePlaceId: number | undefined | null,
20
+ * googlePlaceId: number | string | undefined | null,
21
21
  * title: string | undefined | null,
22
22
  * app: string | undefined | null
23
23
  * dialogTitle: string | undefined | null
@@ -129,21 +129,35 @@ export async function showLocation(options) {
129
129
  case 'google-maps':
130
130
  const googleDirectionMode = getDirectionsModeGoogleMaps();
131
131
  // Always using universal URL instead of URI scheme since the latter doesn't support all parameters (#155)
132
- url = 'https://www.google.com/maps/dir/?api=1';
133
- if (useSourceDestiny) {
132
+ if (useSourceDestiny || options.directionsMode) {
133
+ // Use "dir" as this will open up directions
134
+ url = 'https://www.google.com/maps/dir/?api=1';
134
135
  url += `&origin=${sourceLatLng}`;
135
- }
136
- if (!options.googleForceLatLon && title) {
137
- url += `&destination=${encodedTitle}`;
138
- } else {
139
- url += `&destination=${latlng}`;
140
- }
136
+ if (!options.googleForceLatLon && title) {
137
+ url += `&destination=${encodedTitle}`;
138
+ } else {
139
+ url += `&destination=${latlng}`;
140
+ }
141
141
 
142
- url += options.googlePlaceId
143
- ? `&destination_place_id=${options.googlePlaceId}`
144
- : '';
142
+ url += options.googlePlaceId
143
+ ? `&destination_place_id=${options.googlePlaceId}`
144
+ : '';
145
145
 
146
- url += googleDirectionMode ? `&travelmode=${googleDirectionMode}` : '';
146
+ url += googleDirectionMode ? `&travelmode=${googleDirectionMode}` : '';
147
+ } else {
148
+ // Use "search" as this will open up a single marker
149
+ url = 'https://www.google.com/maps/search/?api=1';
150
+
151
+ if (!options.googleForceLatLon && title) {
152
+ url += `&query=${encodedTitle}`;
153
+ } else {
154
+ url += `&query=${latlng}`;
155
+ }
156
+
157
+ url += options.googlePlaceId
158
+ ? `&query_place_id=${options.googlePlaceId}`
159
+ : '';
160
+ }
147
161
  break;
148
162
  case 'citymapper':
149
163
  url = `${prefixes.citymapper}directions?endcoord=${latlng}`;