@capawesome/capacitor-maps-launcher 0.0.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.
- package/CapawesomeCapacitorMapsLauncher.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +292 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +10 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/MapsLauncher.java +200 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/MapsLauncherPlugin.java +117 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/classes/CustomExceptions.java +15 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/classes/options/Destination.java +57 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/classes/options/NavigateOptions.java +54 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/classes/results/GetAvailableAppsResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/classes/results/GetDefaultAppResult.java +25 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mapslauncher/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +329 -0
- package/dist/esm/definitions.d.ts +195 -0
- package/dist/esm/definitions.js +47 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +7 -0
- package/dist/esm/web.js +13 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +74 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +77 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/Destination.swift +36 -0
- package/ios/Plugin/Classes/Options/NavigateOptions.swift +23 -0
- package/ios/Plugin/Classes/Results/GetAvailableAppsResult.swift +16 -0
- package/ios/Plugin/Enums/CustomError.swift +36 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/MapsLauncher.swift +182 -0
- package/ios/Plugin/MapsLauncherPlugin.swift +71 -0
- package/ios/Plugin/Protocols/Result.swift +5 -0
- package/package.json +94 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export interface MapsLauncherPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Get the navigation apps that are installed and can be launched.
|
|
4
|
+
*
|
|
5
|
+
* On iOS, Apple Maps is always included. Google Maps and Waze are only
|
|
6
|
+
* included if the corresponding `LSApplicationQueriesSchemes` entries are
|
|
7
|
+
* added to the `Info.plist` file of your app.
|
|
8
|
+
*
|
|
9
|
+
* Only available on Android and iOS.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
getAvailableApps(): Promise<GetAvailableAppsResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the navigation app that is configured as the default handler for
|
|
16
|
+
* navigation intents.
|
|
17
|
+
*
|
|
18
|
+
* Returns `null` if the default app is not part of the curated list of
|
|
19
|
+
* supported apps or if no default app is set (i.e. the system shows a
|
|
20
|
+
* chooser).
|
|
21
|
+
*
|
|
22
|
+
* Only available on Android.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
getDefaultApp(): Promise<GetDefaultAppResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Launch a navigation app with turn-by-turn directions to a destination.
|
|
29
|
+
*
|
|
30
|
+
* If no `app` is provided, the system default behavior is used (a chooser on
|
|
31
|
+
* Android, Apple Maps on iOS).
|
|
32
|
+
*
|
|
33
|
+
* Only available on Android and iOS.
|
|
34
|
+
*
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
*/
|
|
37
|
+
navigate(options: NavigateOptions): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
*/
|
|
42
|
+
export interface GetAvailableAppsResult {
|
|
43
|
+
/**
|
|
44
|
+
* The navigation apps that are installed and can be launched.
|
|
45
|
+
*
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
*/
|
|
48
|
+
apps: NavigationApp[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @since 0.1.0
|
|
52
|
+
*/
|
|
53
|
+
export interface GetDefaultAppResult {
|
|
54
|
+
/**
|
|
55
|
+
* The navigation app that is configured as the default handler.
|
|
56
|
+
*
|
|
57
|
+
* Returns `null` if the default app is not part of the curated list of
|
|
58
|
+
* supported apps or if no default app is set.
|
|
59
|
+
*
|
|
60
|
+
* @since 0.1.0
|
|
61
|
+
*/
|
|
62
|
+
app: NavigationApp | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @since 0.1.0
|
|
66
|
+
*/
|
|
67
|
+
export interface NavigateOptions {
|
|
68
|
+
/**
|
|
69
|
+
* The navigation app to launch.
|
|
70
|
+
*
|
|
71
|
+
* If not provided, the system default behavior is used (a chooser on
|
|
72
|
+
* Android, Apple Maps on iOS).
|
|
73
|
+
*
|
|
74
|
+
* @since 0.1.0
|
|
75
|
+
*/
|
|
76
|
+
app?: NavigationApp;
|
|
77
|
+
/**
|
|
78
|
+
* The destination to navigate to.
|
|
79
|
+
*
|
|
80
|
+
* @since 0.1.0
|
|
81
|
+
*/
|
|
82
|
+
destination: Destination;
|
|
83
|
+
/**
|
|
84
|
+
* The start location of the route.
|
|
85
|
+
*
|
|
86
|
+
* If not provided, the current location of the device is used.
|
|
87
|
+
*
|
|
88
|
+
* **Note**: The support depends on the selected app. Apple Maps supports it
|
|
89
|
+
* fully, Google Maps opens the directions preview instead of starting
|
|
90
|
+
* turn-by-turn navigation, and Waze ignores it.
|
|
91
|
+
*
|
|
92
|
+
* @since 0.1.0
|
|
93
|
+
*/
|
|
94
|
+
start?: Destination;
|
|
95
|
+
/**
|
|
96
|
+
* The travel mode to use for the directions.
|
|
97
|
+
*
|
|
98
|
+
* **Note**: The support depends on the selected app and is best-effort.
|
|
99
|
+
* Waze only supports driving and ignores this option.
|
|
100
|
+
*
|
|
101
|
+
* @default 'driving'
|
|
102
|
+
* @since 0.1.0
|
|
103
|
+
*/
|
|
104
|
+
travelMode?: TravelMode;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A destination is either defined by its coordinates or by its address, but
|
|
108
|
+
* not both.
|
|
109
|
+
*
|
|
110
|
+
* @since 0.1.0
|
|
111
|
+
*/
|
|
112
|
+
export interface Destination {
|
|
113
|
+
/**
|
|
114
|
+
* The address of the destination.
|
|
115
|
+
*
|
|
116
|
+
* Must be provided without `latitude` and `longitude`.
|
|
117
|
+
*
|
|
118
|
+
* @example 'Apple Park, Cupertino, CA'
|
|
119
|
+
* @since 0.1.0
|
|
120
|
+
*/
|
|
121
|
+
address?: string;
|
|
122
|
+
/**
|
|
123
|
+
* The latitude of the destination.
|
|
124
|
+
*
|
|
125
|
+
* Must be provided together with `longitude` and without `address`.
|
|
126
|
+
*
|
|
127
|
+
* @example 37.3349
|
|
128
|
+
* @since 0.1.0
|
|
129
|
+
*/
|
|
130
|
+
latitude?: number;
|
|
131
|
+
/**
|
|
132
|
+
* The longitude of the destination.
|
|
133
|
+
*
|
|
134
|
+
* Must be provided together with `latitude` and without `address`.
|
|
135
|
+
*
|
|
136
|
+
* @example -122.009
|
|
137
|
+
* @since 0.1.0
|
|
138
|
+
*/
|
|
139
|
+
longitude?: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A navigation app that can be launched.
|
|
143
|
+
*
|
|
144
|
+
* @since 0.1.0
|
|
145
|
+
*/
|
|
146
|
+
export declare enum NavigationApp {
|
|
147
|
+
/**
|
|
148
|
+
* Apple Maps.
|
|
149
|
+
*
|
|
150
|
+
* Only available on iOS.
|
|
151
|
+
*
|
|
152
|
+
* @since 0.1.0
|
|
153
|
+
*/
|
|
154
|
+
AppleMaps = "appleMaps",
|
|
155
|
+
/**
|
|
156
|
+
* Google Maps.
|
|
157
|
+
*
|
|
158
|
+
* @since 0.1.0
|
|
159
|
+
*/
|
|
160
|
+
GoogleMaps = "googleMaps",
|
|
161
|
+
/**
|
|
162
|
+
* Waze.
|
|
163
|
+
*
|
|
164
|
+
* @since 0.1.0
|
|
165
|
+
*/
|
|
166
|
+
Waze = "waze"
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The travel mode to use for the directions.
|
|
170
|
+
*
|
|
171
|
+
* - `driving`: Driving directions.
|
|
172
|
+
* - `walking`: Walking directions.
|
|
173
|
+
* - `bicycling`: Bicycling directions.
|
|
174
|
+
* - `transit`: Public transit directions.
|
|
175
|
+
*
|
|
176
|
+
* @since 0.1.0
|
|
177
|
+
*/
|
|
178
|
+
export type TravelMode = 'driving' | 'walking' | 'bicycling' | 'transit';
|
|
179
|
+
/**
|
|
180
|
+
* @since 0.1.0
|
|
181
|
+
*/
|
|
182
|
+
export declare enum ErrorCode {
|
|
183
|
+
/**
|
|
184
|
+
* The requested navigation app is not installed or cannot be launched.
|
|
185
|
+
*
|
|
186
|
+
* @since 0.1.0
|
|
187
|
+
*/
|
|
188
|
+
AppNotAvailable = "APP_NOT_AVAILABLE",
|
|
189
|
+
/**
|
|
190
|
+
* The navigation app could not be launched.
|
|
191
|
+
*
|
|
192
|
+
* @since 0.1.0
|
|
193
|
+
*/
|
|
194
|
+
LaunchFailed = "LAUNCH_FAILED"
|
|
195
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A navigation app that can be launched.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
export var NavigationApp;
|
|
7
|
+
(function (NavigationApp) {
|
|
8
|
+
/**
|
|
9
|
+
* Apple Maps.
|
|
10
|
+
*
|
|
11
|
+
* Only available on iOS.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
NavigationApp["AppleMaps"] = "appleMaps";
|
|
16
|
+
/**
|
|
17
|
+
* Google Maps.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
NavigationApp["GoogleMaps"] = "googleMaps";
|
|
22
|
+
/**
|
|
23
|
+
* Waze.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
*/
|
|
27
|
+
NavigationApp["Waze"] = "waze";
|
|
28
|
+
})(NavigationApp || (NavigationApp = {}));
|
|
29
|
+
/**
|
|
30
|
+
* @since 0.1.0
|
|
31
|
+
*/
|
|
32
|
+
export var ErrorCode;
|
|
33
|
+
(function (ErrorCode) {
|
|
34
|
+
/**
|
|
35
|
+
* The requested navigation app is not installed or cannot be launched.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.1.0
|
|
38
|
+
*/
|
|
39
|
+
ErrorCode["AppNotAvailable"] = "APP_NOT_AVAILABLE";
|
|
40
|
+
/**
|
|
41
|
+
* The navigation app could not be launched.
|
|
42
|
+
*
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
*/
|
|
45
|
+
ErrorCode["LaunchFailed"] = "LAUNCH_FAILED";
|
|
46
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
47
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAiJA;;;;GAIG;AACH,MAAM,CAAN,IAAY,aAqBX;AArBD,WAAY,aAAa;IACvB;;;;;;OAMG;IACH,wCAAuB,CAAA;IACvB;;;;OAIG;IACH,0CAAyB,CAAA;IACzB;;;;OAIG;IACH,8BAAa,CAAA;AACf,CAAC,EArBW,aAAa,KAAb,aAAa,QAqBxB;AAcD;;GAEG;AACH,MAAM,CAAN,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB;;;;OAIG;IACH,kDAAqC,CAAA;IACrC;;;;OAIG;IACH,2CAA8B,CAAA;AAChC,CAAC,EAbW,SAAS,KAAT,SAAS,QAapB","sourcesContent":["export interface MapsLauncherPlugin {\n /**\n * Get the navigation apps that are installed and can be launched.\n *\n * On iOS, Apple Maps is always included. Google Maps and Waze are only\n * included if the corresponding `LSApplicationQueriesSchemes` entries are\n * added to the `Info.plist` file of your app.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n getAvailableApps(): Promise<GetAvailableAppsResult>;\n /**\n * Get the navigation app that is configured as the default handler for\n * navigation intents.\n *\n * Returns `null` if the default app is not part of the curated list of\n * supported apps or if no default app is set (i.e. the system shows a\n * chooser).\n *\n * Only available on Android.\n *\n * @since 0.1.0\n */\n getDefaultApp(): Promise<GetDefaultAppResult>;\n /**\n * Launch a navigation app with turn-by-turn directions to a destination.\n *\n * If no `app` is provided, the system default behavior is used (a chooser on\n * Android, Apple Maps on iOS).\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n navigate(options: NavigateOptions): Promise<void>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface GetAvailableAppsResult {\n /**\n * The navigation apps that are installed and can be launched.\n *\n * @since 0.1.0\n */\n apps: NavigationApp[];\n}\n\n/**\n * @since 0.1.0\n */\nexport interface GetDefaultAppResult {\n /**\n * The navigation app that is configured as the default handler.\n *\n * Returns `null` if the default app is not part of the curated list of\n * supported apps or if no default app is set.\n *\n * @since 0.1.0\n */\n app: NavigationApp | null;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface NavigateOptions {\n /**\n * The navigation app to launch.\n *\n * If not provided, the system default behavior is used (a chooser on\n * Android, Apple Maps on iOS).\n *\n * @since 0.1.0\n */\n app?: NavigationApp;\n /**\n * The destination to navigate to.\n *\n * @since 0.1.0\n */\n destination: Destination;\n /**\n * The start location of the route.\n *\n * If not provided, the current location of the device is used.\n *\n * **Note**: The support depends on the selected app. Apple Maps supports it\n * fully, Google Maps opens the directions preview instead of starting\n * turn-by-turn navigation, and Waze ignores it.\n *\n * @since 0.1.0\n */\n start?: Destination;\n /**\n * The travel mode to use for the directions.\n *\n * **Note**: The support depends on the selected app and is best-effort.\n * Waze only supports driving and ignores this option.\n *\n * @default 'driving'\n * @since 0.1.0\n */\n travelMode?: TravelMode;\n}\n\n/**\n * A destination is either defined by its coordinates or by its address, but\n * not both.\n *\n * @since 0.1.0\n */\nexport interface Destination {\n /**\n * The address of the destination.\n *\n * Must be provided without `latitude` and `longitude`.\n *\n * @example 'Apple Park, Cupertino, CA'\n * @since 0.1.0\n */\n address?: string;\n /**\n * The latitude of the destination.\n *\n * Must be provided together with `longitude` and without `address`.\n *\n * @example 37.3349\n * @since 0.1.0\n */\n latitude?: number;\n /**\n * The longitude of the destination.\n *\n * Must be provided together with `latitude` and without `address`.\n *\n * @example -122.009\n * @since 0.1.0\n */\n longitude?: number;\n}\n\n/**\n * A navigation app that can be launched.\n *\n * @since 0.1.0\n */\nexport enum NavigationApp {\n /**\n * Apple Maps.\n *\n * Only available on iOS.\n *\n * @since 0.1.0\n */\n AppleMaps = 'appleMaps',\n /**\n * Google Maps.\n *\n * @since 0.1.0\n */\n GoogleMaps = 'googleMaps',\n /**\n * Waze.\n *\n * @since 0.1.0\n */\n Waze = 'waze',\n}\n\n/**\n * The travel mode to use for the directions.\n *\n * - `driving`: Driving directions.\n * - `walking`: Walking directions.\n * - `bicycling`: Bicycling directions.\n * - `transit`: Public transit directions.\n *\n * @since 0.1.0\n */\nexport type TravelMode = 'driving' | 'walking' | 'bicycling' | 'transit';\n\n/**\n * @since 0.1.0\n */\nexport enum ErrorCode {\n /**\n * The requested navigation app is not installed or cannot be launched.\n *\n * @since 0.1.0\n */\n AppNotAvailable = 'APP_NOT_AVAILABLE',\n /**\n * The navigation app could not be launched.\n *\n * @since 0.1.0\n */\n LaunchFailed = 'LAUNCH_FAILED',\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const MapsLauncher = registerPlugin('MapsLauncher', {
|
|
3
|
+
web: () => import('./web').then(m => new m.MapsLauncherWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { MapsLauncher };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { MapsLauncherPlugin } from './definitions';\n\nconst MapsLauncher = registerPlugin<MapsLauncherPlugin>('MapsLauncher', {\n web: () => import('./web').then(m => new m.MapsLauncherWeb()),\n});\n\nexport * from './definitions';\nexport { MapsLauncher };\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { GetAvailableAppsResult, GetDefaultAppResult, MapsLauncherPlugin, NavigateOptions } from './definitions';
|
|
3
|
+
export declare class MapsLauncherWeb extends WebPlugin implements MapsLauncherPlugin {
|
|
4
|
+
getAvailableApps(): Promise<GetAvailableAppsResult>;
|
|
5
|
+
getDefaultApp(): Promise<GetDefaultAppResult>;
|
|
6
|
+
navigate(_options: NavigateOptions): Promise<void>;
|
|
7
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class MapsLauncherWeb extends WebPlugin {
|
|
3
|
+
async getAvailableApps() {
|
|
4
|
+
throw this.unimplemented('Not implemented on web.');
|
|
5
|
+
}
|
|
6
|
+
async getDefaultApp() {
|
|
7
|
+
throw this.unimplemented('Not implemented on web.');
|
|
8
|
+
}
|
|
9
|
+
async navigate(_options) {
|
|
10
|
+
throw this.unimplemented('Not implemented on web.');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAyB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n GetAvailableAppsResult,\n GetDefaultAppResult,\n MapsLauncherPlugin,\n NavigateOptions,\n} from './definitions';\n\nexport class MapsLauncherWeb extends WebPlugin implements MapsLauncherPlugin {\n async getAvailableApps(): Promise<GetAvailableAppsResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getDefaultApp(): Promise<GetDefaultAppResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async navigate(_options: NavigateOptions): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A navigation app that can be launched.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
exports.NavigationApp = void 0;
|
|
11
|
+
(function (NavigationApp) {
|
|
12
|
+
/**
|
|
13
|
+
* Apple Maps.
|
|
14
|
+
*
|
|
15
|
+
* Only available on iOS.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
NavigationApp["AppleMaps"] = "appleMaps";
|
|
20
|
+
/**
|
|
21
|
+
* Google Maps.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
NavigationApp["GoogleMaps"] = "googleMaps";
|
|
26
|
+
/**
|
|
27
|
+
* Waze.
|
|
28
|
+
*
|
|
29
|
+
* @since 0.1.0
|
|
30
|
+
*/
|
|
31
|
+
NavigationApp["Waze"] = "waze";
|
|
32
|
+
})(exports.NavigationApp || (exports.NavigationApp = {}));
|
|
33
|
+
/**
|
|
34
|
+
* @since 0.1.0
|
|
35
|
+
*/
|
|
36
|
+
exports.ErrorCode = void 0;
|
|
37
|
+
(function (ErrorCode) {
|
|
38
|
+
/**
|
|
39
|
+
* The requested navigation app is not installed or cannot be launched.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
*/
|
|
43
|
+
ErrorCode["AppNotAvailable"] = "APP_NOT_AVAILABLE";
|
|
44
|
+
/**
|
|
45
|
+
* The navigation app could not be launched.
|
|
46
|
+
*
|
|
47
|
+
* @since 0.1.0
|
|
48
|
+
*/
|
|
49
|
+
ErrorCode["LaunchFailed"] = "LAUNCH_FAILED";
|
|
50
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
51
|
+
|
|
52
|
+
const MapsLauncher = core.registerPlugin('MapsLauncher', {
|
|
53
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.MapsLauncherWeb()),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
class MapsLauncherWeb extends core.WebPlugin {
|
|
57
|
+
async getAvailableApps() {
|
|
58
|
+
throw this.unimplemented('Not implemented on web.');
|
|
59
|
+
}
|
|
60
|
+
async getDefaultApp() {
|
|
61
|
+
throw this.unimplemented('Not implemented on web.');
|
|
62
|
+
}
|
|
63
|
+
async navigate(_options) {
|
|
64
|
+
throw this.unimplemented('Not implemented on web.');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
69
|
+
__proto__: null,
|
|
70
|
+
MapsLauncherWeb: MapsLauncherWeb
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
exports.MapsLauncher = MapsLauncher;
|
|
74
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * A navigation app that can be launched.\n *\n * @since 0.1.0\n */\nexport var NavigationApp;\n(function (NavigationApp) {\n /**\n * Apple Maps.\n *\n * Only available on iOS.\n *\n * @since 0.1.0\n */\n NavigationApp[\"AppleMaps\"] = \"appleMaps\";\n /**\n * Google Maps.\n *\n * @since 0.1.0\n */\n NavigationApp[\"GoogleMaps\"] = \"googleMaps\";\n /**\n * Waze.\n *\n * @since 0.1.0\n */\n NavigationApp[\"Waze\"] = \"waze\";\n})(NavigationApp || (NavigationApp = {}));\n/**\n * @since 0.1.0\n */\nexport var ErrorCode;\n(function (ErrorCode) {\n /**\n * The requested navigation app is not installed or cannot be launched.\n *\n * @since 0.1.0\n */\n ErrorCode[\"AppNotAvailable\"] = \"APP_NOT_AVAILABLE\";\n /**\n * The navigation app could not be launched.\n *\n * @since 0.1.0\n */\n ErrorCode[\"LaunchFailed\"] = \"LAUNCH_FAILED\";\n})(ErrorCode || (ErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst MapsLauncher = registerPlugin('MapsLauncher', {\n web: () => import('./web').then(m => new m.MapsLauncherWeb()),\n});\nexport * from './definitions';\nexport { MapsLauncher };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MapsLauncherWeb extends WebPlugin {\n async getAvailableApps() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getDefaultApp() {\n throw this.unimplemented('Not implemented on web.');\n }\n async navigate(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NavigationApp","ErrorCode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,WAAW,CAAC,GAAG,WAAW;AAC5C;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,YAAY;AAC9C;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;AAClC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;AACzC;AACA;AACA;AACWC;AACX,CAAC,UAAU,SAAS,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,iBAAiB,CAAC,GAAG,mBAAmB;AACtD;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,eAAe;AAC/C,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC;;AC5C5B,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var capacitorMapsLauncher = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A navigation app that can be launched.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
*/
|
|
9
|
+
exports.NavigationApp = void 0;
|
|
10
|
+
(function (NavigationApp) {
|
|
11
|
+
/**
|
|
12
|
+
* Apple Maps.
|
|
13
|
+
*
|
|
14
|
+
* Only available on iOS.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.1.0
|
|
17
|
+
*/
|
|
18
|
+
NavigationApp["AppleMaps"] = "appleMaps";
|
|
19
|
+
/**
|
|
20
|
+
* Google Maps.
|
|
21
|
+
*
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
*/
|
|
24
|
+
NavigationApp["GoogleMaps"] = "googleMaps";
|
|
25
|
+
/**
|
|
26
|
+
* Waze.
|
|
27
|
+
*
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
NavigationApp["Waze"] = "waze";
|
|
31
|
+
})(exports.NavigationApp || (exports.NavigationApp = {}));
|
|
32
|
+
/**
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
*/
|
|
35
|
+
exports.ErrorCode = void 0;
|
|
36
|
+
(function (ErrorCode) {
|
|
37
|
+
/**
|
|
38
|
+
* The requested navigation app is not installed or cannot be launched.
|
|
39
|
+
*
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
*/
|
|
42
|
+
ErrorCode["AppNotAvailable"] = "APP_NOT_AVAILABLE";
|
|
43
|
+
/**
|
|
44
|
+
* The navigation app could not be launched.
|
|
45
|
+
*
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
*/
|
|
48
|
+
ErrorCode["LaunchFailed"] = "LAUNCH_FAILED";
|
|
49
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
50
|
+
|
|
51
|
+
const MapsLauncher = core.registerPlugin('MapsLauncher', {
|
|
52
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.MapsLauncherWeb()),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
class MapsLauncherWeb extends core.WebPlugin {
|
|
56
|
+
async getAvailableApps() {
|
|
57
|
+
throw this.unimplemented('Not implemented on web.');
|
|
58
|
+
}
|
|
59
|
+
async getDefaultApp() {
|
|
60
|
+
throw this.unimplemented('Not implemented on web.');
|
|
61
|
+
}
|
|
62
|
+
async navigate(_options) {
|
|
63
|
+
throw this.unimplemented('Not implemented on web.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
68
|
+
__proto__: null,
|
|
69
|
+
MapsLauncherWeb: MapsLauncherWeb
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
exports.MapsLauncher = MapsLauncher;
|
|
73
|
+
|
|
74
|
+
return exports;
|
|
75
|
+
|
|
76
|
+
})({}, capacitorExports);
|
|
77
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * A navigation app that can be launched.\n *\n * @since 0.1.0\n */\nexport var NavigationApp;\n(function (NavigationApp) {\n /**\n * Apple Maps.\n *\n * Only available on iOS.\n *\n * @since 0.1.0\n */\n NavigationApp[\"AppleMaps\"] = \"appleMaps\";\n /**\n * Google Maps.\n *\n * @since 0.1.0\n */\n NavigationApp[\"GoogleMaps\"] = \"googleMaps\";\n /**\n * Waze.\n *\n * @since 0.1.0\n */\n NavigationApp[\"Waze\"] = \"waze\";\n})(NavigationApp || (NavigationApp = {}));\n/**\n * @since 0.1.0\n */\nexport var ErrorCode;\n(function (ErrorCode) {\n /**\n * The requested navigation app is not installed or cannot be launched.\n *\n * @since 0.1.0\n */\n ErrorCode[\"AppNotAvailable\"] = \"APP_NOT_AVAILABLE\";\n /**\n * The navigation app could not be launched.\n *\n * @since 0.1.0\n */\n ErrorCode[\"LaunchFailed\"] = \"LAUNCH_FAILED\";\n})(ErrorCode || (ErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst MapsLauncher = registerPlugin('MapsLauncher', {\n web: () => import('./web').then(m => new m.MapsLauncherWeb()),\n});\nexport * from './definitions';\nexport { MapsLauncher };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MapsLauncherWeb extends WebPlugin {\n async getAvailableApps() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getDefaultApp() {\n throw this.unimplemented('Not implemented on web.');\n }\n async navigate(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NavigationApp","ErrorCode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,WAAW,CAAC,GAAG,WAAW;IAC5C;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,YAAY;IAC9C;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IAClC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;IACzC;IACA;IACA;AACWC;IACX,CAAC,UAAU,SAAS,EAAE;IACtB;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,iBAAiB,CAAC,GAAG,mBAAmB;IACtD;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,eAAe;IAC/C,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC;;AC5C5B,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import CoreLocation
|
|
4
|
+
|
|
5
|
+
@objc public class Destination: NSObject {
|
|
6
|
+
let address: String?
|
|
7
|
+
let latitude: Double?
|
|
8
|
+
let longitude: Double?
|
|
9
|
+
|
|
10
|
+
var coordinate: CLLocationCoordinate2D? {
|
|
11
|
+
guard let latitude = latitude, let longitude = longitude else {
|
|
12
|
+
return nil
|
|
13
|
+
}
|
|
14
|
+
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
init(_ object: JSObject) throws {
|
|
18
|
+
let latitude = (object["latitude"] as? NSNumber)?.doubleValue
|
|
19
|
+
let longitude = (object["longitude"] as? NSNumber)?.doubleValue
|
|
20
|
+
let address = (object["address"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
21
|
+
let hasCoordinates = latitude != nil && longitude != nil
|
|
22
|
+
let hasAddress = address != nil && !(address?.isEmpty ?? true)
|
|
23
|
+
if hasCoordinates == hasAddress {
|
|
24
|
+
throw CustomError.destinationInvalid
|
|
25
|
+
}
|
|
26
|
+
if hasCoordinates {
|
|
27
|
+
self.latitude = latitude
|
|
28
|
+
self.longitude = longitude
|
|
29
|
+
self.address = nil
|
|
30
|
+
} else {
|
|
31
|
+
self.latitude = nil
|
|
32
|
+
self.longitude = nil
|
|
33
|
+
self.address = address
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class NavigateOptions: NSObject {
|
|
5
|
+
let app: String?
|
|
6
|
+
let destination: Destination
|
|
7
|
+
let start: Destination?
|
|
8
|
+
let travelMode: String?
|
|
9
|
+
|
|
10
|
+
init(_ call: CAPPluginCall) throws {
|
|
11
|
+
guard let destinationObject = call.getObject("destination") else {
|
|
12
|
+
throw CustomError.destinationMissing
|
|
13
|
+
}
|
|
14
|
+
self.destination = try Destination(destinationObject)
|
|
15
|
+
if let startObject = call.getObject("start") {
|
|
16
|
+
self.start = try Destination(startObject)
|
|
17
|
+
} else {
|
|
18
|
+
self.start = nil
|
|
19
|
+
}
|
|
20
|
+
self.app = call.getString("app")
|
|
21
|
+
self.travelMode = call.getString("travelMode")
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class GetAvailableAppsResult: NSObject, Result {
|
|
5
|
+
let apps: [String]
|
|
6
|
+
|
|
7
|
+
init(apps: [String]) {
|
|
8
|
+
self.apps = apps
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["apps"] = apps
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum CustomError: Error {
|
|
4
|
+
case appNotAvailable
|
|
5
|
+
case destinationInvalid
|
|
6
|
+
case destinationMissing
|
|
7
|
+
case launchFailed
|
|
8
|
+
|
|
9
|
+
var code: String? {
|
|
10
|
+
switch self {
|
|
11
|
+
case .appNotAvailable:
|
|
12
|
+
return "APP_NOT_AVAILABLE"
|
|
13
|
+
case .destinationInvalid:
|
|
14
|
+
return nil
|
|
15
|
+
case .destinationMissing:
|
|
16
|
+
return nil
|
|
17
|
+
case .launchFailed:
|
|
18
|
+
return "LAUNCH_FAILED"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
extension CustomError: LocalizedError {
|
|
24
|
+
public var errorDescription: String? {
|
|
25
|
+
switch self {
|
|
26
|
+
case .appNotAvailable:
|
|
27
|
+
return NSLocalizedString("The requested navigation app is not installed or cannot be launched.", comment: "appNotAvailable")
|
|
28
|
+
case .destinationInvalid:
|
|
29
|
+
return NSLocalizedString("destination must contain either coordinates or an address, but not both.", comment: "destinationInvalid")
|
|
30
|
+
case .destinationMissing:
|
|
31
|
+
return NSLocalizedString("destination must be provided.", comment: "destinationMissing")
|
|
32
|
+
case .launchFailed:
|
|
33
|
+
return NSLocalizedString("The navigation app could not be launched.", comment: "launchFailed")
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|