ADU
zsT`T;C|v*m
literal 0
HcmV?d00001
diff --git a/src/type.ts b/src/type.ts
index 74060c9..7a7e98c 100644
--- a/src/type.ts
+++ b/src/type.ts
@@ -24,7 +24,8 @@ export type MapId =
| 'dgis'
| 'liftago'
| 'petalmaps'
- | 'sygic';
+ | 'sygic'
+ | 'w3w';
export type DirectionMode = 'car' | 'walk' | 'public-transport' | 'bike';
diff --git a/src/utils.ts b/src/utils.ts
index 89a992f..a910c42 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -556,6 +556,16 @@ export const generateMapUrl = ({
url = `${prefixes.sygic}coordinate|${lng}|${lat}|`;
}
url += sygicDirectionsMode ? `${sygicDirectionsMode}` : '';
+ break;
+ case 'w3w':
+ // w3w only supports passing the 3 word reference or the current user location
+ // https://developer.what3words.com/tutorial/mobile-linking-to-the-what3words-app#supported-uris
+ if (address) {
+ url = `${prefixes.w3w}show?threewords=${address}`;
+ } else {
+ url = `${prefixes.w3w}show?currentlocation`;
+ }
+
break;
}
From d52cc0ff6b3b44a5ffe36d58aeede9fceed8682a Mon Sep 17 00:00:00 2001
From: Luke <66969275+lcorbett89@users.noreply.github.com>
Date: Sat, 15 Mar 2025 22:59:20 +0000
Subject: [PATCH 2/4] add tests
---
tests/index.test.ts | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/index.test.ts b/tests/index.test.ts
index 0e039c8..c90a90d 100644
--- a/tests/index.test.ts
+++ b/tests/index.test.ts
@@ -634,4 +634,26 @@ describe('showLocation', () => {
);
});
});
+ describe('w3w', () => {
+ it('opens with correct url if address is not provided', () => {
+ verifyThatSettingsLeadToUrl(
+ {
+ latitude,
+ longitude,
+ app: 'w3w',
+ },
+ 'w3w://show?currentlocation',
+ );
+ });
+
+ it('opens with correct url if address (w3w) is provided', () => {
+ verifyThatSettingsLeadToUrl(
+ {
+ app: 'w3w',
+ address: 'test.three.words',
+ },
+ 'w3w://show?threewords=test.three.words',
+ );
+ });
+ });
});
From 39e7ad24482f4b1d4b1b1598f00d7f019177747a Mon Sep 17 00:00:00 2001
From: Luke <66969275+lcorbett89@users.noreply.github.com>
Date: Sat, 15 Mar 2025 23:40:44 +0000
Subject: [PATCH 3/4] add 'words' field instead of using 'address' as this
breaks apple maps directions
---
src/index.ts | 3 +++
src/type.ts | 1 +
src/utils.ts | 11 +++++++++--
tests/index.test.ts | 4 +++-
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/index.ts b/src/index.ts
index d567049..4640da0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -26,6 +26,7 @@ export const showLocation = async ({
latitude,
longitude,
address,
+ words,
sourceLatitude,
sourceLongitude,
appleIgnoreLatLon,
@@ -52,6 +53,7 @@ export const showLocation = async ({
latitude,
longitude,
address,
+ words,
googleForceLatLon,
googlePlaceId,
title: customTitle,
@@ -135,6 +137,7 @@ export const showLocation = async ({
sourceLng,
sourceLatLng,
address: fullAddress,
+ words,
title,
encodedTitle,
prefixes,
diff --git a/src/type.ts b/src/type.ts
index 7a7e98c..a1c12aa 100644
--- a/src/type.ts
+++ b/src/type.ts
@@ -51,6 +51,7 @@ export interface ShowLocationProps {
/** optionally you can enter a full address that will be queried against the map app's API and return the initial results if not the actual matched result. */
/** latitude and longitude will be ignored if the address field is set */
address?: string | null;
+ words?: string | null;
sourceLatitude?: number | null;
sourceLongitude?: number | null;
appleIgnoreLatLon?: boolean;
diff --git a/src/utils.ts b/src/utils.ts
index a910c42..4696bc4 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -175,6 +175,7 @@ export const checkOptions = ({
latitude,
longitude,
address,
+ words,
googleForceLatLon,
googlePlaceId,
title,
@@ -186,6 +187,7 @@ export const checkOptions = ({
latitude?: number | string;
longitude?: number | string;
address?: string | null;
+ words?: string | null;
googleForceLatLon?: boolean | null | undefined;
googlePlaceId?: number | string | null | undefined;
title?: string | null | undefined;
@@ -202,6 +204,9 @@ export const checkOptions = ({
if (address && typeof address !== 'string') {
throw new MapsException('Option `address` should be of type `string`.');
}
+ if (words && typeof words !== 'string') {
+ throw new MapsException('Option `words` should be of type `string`.');
+ }
if (title && typeof title !== 'string') {
throw new MapsException('`title` should be of type `string`.');
}
@@ -244,6 +249,7 @@ export const generateMapUrl = ({
sourceLng,
sourceLatLng,
address,
+ words,
title,
encodedTitle,
prefixes,
@@ -262,6 +268,7 @@ export const generateMapUrl = ({
sourceLng?: number;
sourceLatLng?: string;
address?: string | null;
+ words?: string | null;
title?: string | null;
encodedTitle?: string;
prefixes: Record