capacitor-google-navigation 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/CapacitorGoogleNavigation.podspec +18 -0
- package/Package.swift +28 -0
- package/README.md +486 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/attributeai/navigation/GoogleNavigation.java +152 -0
- package/android/src/main/java/com/attributeai/navigation/GoogleNavigationPlugin.java +87 -0
- package/android/src/main/java/com/attributeai/navigation/NavigationFragment.java +74 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +123 -0
- package/dist/esm/definitions.d.ts +45 -0
- package/dist/esm/definitions.js +2 -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 +24 -0
- package/dist/esm/web.js +16 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +30 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +33 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/GoogleNavigationPlugin/GoogleNavigation.swift +110 -0
- package/ios/Sources/GoogleNavigationPlugin/GoogleNavigationPlugin.swift +69 -0
- package/ios/Tests/GoogleNavigationPluginTests/GoogleNavigationTests.swift +15 -0
- package/package.json +80 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
package com.attributeai.navigation;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
|
|
5
|
+
import androidx.fragment.app.FragmentActivity;
|
|
6
|
+
import androidx.fragment.app.FragmentManager;
|
|
7
|
+
|
|
8
|
+
import com.getcapacitor.JSObject;
|
|
9
|
+
import com.getcapacitor.Logger;
|
|
10
|
+
import com.google.android.libraries.navigation.NavigationApi;
|
|
11
|
+
import com.google.android.libraries.navigation.Navigator;
|
|
12
|
+
import com.google.android.libraries.navigation.RoutingOptions;
|
|
13
|
+
import com.google.android.libraries.navigation.Waypoint;
|
|
14
|
+
|
|
15
|
+
public class GoogleNavigation {
|
|
16
|
+
|
|
17
|
+
interface Callback {
|
|
18
|
+
void onResult(boolean success, String error);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private final GoogleNavigationPlugin plugin;
|
|
22
|
+
private Navigator navigator;
|
|
23
|
+
private static final String TAG = "GoogleNavigation";
|
|
24
|
+
private static final String FRAGMENT_TAG = "GoogleNavigationFragment";
|
|
25
|
+
|
|
26
|
+
public GoogleNavigation(GoogleNavigationPlugin plugin) {
|
|
27
|
+
this.plugin = plugin;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public void initialize(String apiKey, Callback callback) {
|
|
31
|
+
// On Android, the Navigation SDK reads the API key from AndroidManifest
|
|
32
|
+
// <meta-data android:name="com.google.android.geo.API_KEY" android:value="..."/>
|
|
33
|
+
// The apiKey param is accepted for API consistency but not injected programmatically.
|
|
34
|
+
NavigationApi.getNavigator(
|
|
35
|
+
plugin.getActivity().getApplication(),
|
|
36
|
+
new NavigationApi.NavigatorListener() {
|
|
37
|
+
@Override
|
|
38
|
+
public void onNavigatorReady(Navigator nav) {
|
|
39
|
+
navigator = nav;
|
|
40
|
+
attachListeners();
|
|
41
|
+
JSObject data = new JSObject();
|
|
42
|
+
plugin.fireEvent("onNavigationReady", data);
|
|
43
|
+
callback.onResult(true, null);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
public void onError(int errorCode) {
|
|
48
|
+
String msg = "NavigationApi error code: " + errorCode;
|
|
49
|
+
Logger.error(TAG, msg, null);
|
|
50
|
+
callback.onResult(false, msg);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public void startNavigation(double lat, double lng, String travelMode, Callback callback) {
|
|
57
|
+
if (navigator == null) {
|
|
58
|
+
callback.onResult(false, "Call initialize() first");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Waypoint destination;
|
|
63
|
+
try {
|
|
64
|
+
destination = new Waypoint.Builder()
|
|
65
|
+
.setLatLng(lat, lng)
|
|
66
|
+
.setTitle("Destination")
|
|
67
|
+
.build();
|
|
68
|
+
} catch (Waypoint.UnsupportedTravelModeException e) {
|
|
69
|
+
callback.onResult(false, "Unsupported travel mode");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
RoutingOptions.TravelMode mode;
|
|
74
|
+
switch (travelMode) {
|
|
75
|
+
case "WALKING": mode = RoutingOptions.TravelMode.WALKING; break;
|
|
76
|
+
case "CYCLING": mode = RoutingOptions.TravelMode.CYCLING; break;
|
|
77
|
+
case "TWO_WHEELER": mode = RoutingOptions.TravelMode.TWO_WHEELER; break;
|
|
78
|
+
default: mode = RoutingOptions.TravelMode.DRIVING; break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
RoutingOptions routingOptions = new RoutingOptions.Builder()
|
|
82
|
+
.travelMode(mode)
|
|
83
|
+
.build();
|
|
84
|
+
|
|
85
|
+
navigator.setDestination(destination, routingOptions,
|
|
86
|
+
new Navigator.RouteStatusListener() {
|
|
87
|
+
@Override
|
|
88
|
+
public void onRouteStatusResult(Navigator.RouteStatus status) {
|
|
89
|
+
if (status == Navigator.RouteStatus.OK) {
|
|
90
|
+
navigator.startGuidance();
|
|
91
|
+
callback.onResult(true, null);
|
|
92
|
+
} else {
|
|
93
|
+
callback.onResult(false, "Route error: " + status.name());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public void stopNavigation() {
|
|
101
|
+
if (navigator != null) {
|
|
102
|
+
navigator.stopGuidance();
|
|
103
|
+
navigator.clearDestinations();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public void showNavigationView(Activity activity, Callback callback) {
|
|
108
|
+
if (!(activity instanceof FragmentActivity)) {
|
|
109
|
+
callback.onResult(false, "Activity must be a FragmentActivity");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
FragmentActivity fragmentActivity = (FragmentActivity) activity;
|
|
113
|
+
FragmentManager fm = fragmentActivity.getSupportFragmentManager();
|
|
114
|
+
|
|
115
|
+
if (fm.findFragmentByTag(FRAGMENT_TAG) != null) {
|
|
116
|
+
callback.onResult(true, null);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
NavigationFragment fragment = NavigationFragment.newInstance();
|
|
121
|
+
fm.beginTransaction()
|
|
122
|
+
.add(android.R.id.content, fragment, FRAGMENT_TAG)
|
|
123
|
+
.commitAllowingStateLoss();
|
|
124
|
+
callback.onResult(true, null);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public void hideNavigationView(Activity activity) {
|
|
128
|
+
if (!(activity instanceof FragmentActivity)) return;
|
|
129
|
+
FragmentActivity fragmentActivity = (FragmentActivity) activity;
|
|
130
|
+
FragmentManager fm = fragmentActivity.getSupportFragmentManager();
|
|
131
|
+
androidx.fragment.app.Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG);
|
|
132
|
+
if (fragment != null) {
|
|
133
|
+
fm.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private void attachListeners() {
|
|
138
|
+
if (navigator == null) return;
|
|
139
|
+
|
|
140
|
+
navigator.addArrivalListener(waypoint -> {
|
|
141
|
+
JSObject data = new JSObject();
|
|
142
|
+
data.put("latitude", waypoint.getPosition().latitude);
|
|
143
|
+
data.put("longitude", waypoint.getPosition().longitude);
|
|
144
|
+
data.put("title", waypoint.getTitle());
|
|
145
|
+
plugin.fireEvent("onArrival", data);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
navigator.addRouteChangedListener(() -> {
|
|
149
|
+
plugin.fireEvent("onRouteChanged", new JSObject());
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package com.attributeai.navigation;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "GoogleNavigation")
|
|
10
|
+
public class GoogleNavigationPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
private GoogleNavigation implementation;
|
|
13
|
+
|
|
14
|
+
@Override
|
|
15
|
+
public void load() {
|
|
16
|
+
implementation = new GoogleNavigation(this);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void fireEvent(String eventName, JSObject data) {
|
|
20
|
+
notifyListeners(eventName, data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@PluginMethod
|
|
24
|
+
public void initialize(PluginCall call) {
|
|
25
|
+
String apiKey = call.getString("apiKey", "");
|
|
26
|
+
implementation.initialize(apiKey, (success, error) -> {
|
|
27
|
+
if (error != null) {
|
|
28
|
+
call.reject(error);
|
|
29
|
+
} else {
|
|
30
|
+
JSObject ret = new JSObject();
|
|
31
|
+
ret.put("success", true);
|
|
32
|
+
call.resolve(ret);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@PluginMethod
|
|
38
|
+
public void startNavigation(PluginCall call) {
|
|
39
|
+
Double lat = call.getDouble("destinationLatitude");
|
|
40
|
+
Double lng = call.getDouble("destinationLongitude");
|
|
41
|
+
if (lat == null || lng == null) {
|
|
42
|
+
call.reject("destinationLatitude and destinationLongitude are required");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
String travelMode = call.getString("travelMode", "DRIVING");
|
|
46
|
+
implementation.startNavigation(lat, lng, travelMode, (success, error) -> {
|
|
47
|
+
if (error != null) {
|
|
48
|
+
call.reject(error);
|
|
49
|
+
} else {
|
|
50
|
+
JSObject ret = new JSObject();
|
|
51
|
+
ret.put("success", true);
|
|
52
|
+
call.resolve(ret);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@PluginMethod
|
|
58
|
+
public void stopNavigation(PluginCall call) {
|
|
59
|
+
implementation.stopNavigation();
|
|
60
|
+
JSObject ret = new JSObject();
|
|
61
|
+
ret.put("success", true);
|
|
62
|
+
call.resolve(ret);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@PluginMethod
|
|
66
|
+
public void showNavigationView(PluginCall call) {
|
|
67
|
+
boolean show = Boolean.TRUE.equals(call.getBoolean("show", true));
|
|
68
|
+
getActivity().runOnUiThread(() -> {
|
|
69
|
+
if (show) {
|
|
70
|
+
implementation.showNavigationView(getActivity(), (success, error) -> {
|
|
71
|
+
if (error != null) {
|
|
72
|
+
call.reject(error);
|
|
73
|
+
} else {
|
|
74
|
+
JSObject ret = new JSObject();
|
|
75
|
+
ret.put("success", true);
|
|
76
|
+
call.resolve(ret);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
implementation.hideNavigationView(getActivity());
|
|
81
|
+
JSObject ret = new JSObject();
|
|
82
|
+
ret.put("success", true);
|
|
83
|
+
call.resolve(ret);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
package com.attributeai.navigation;
|
|
2
|
+
|
|
3
|
+
import android.os.Bundle;
|
|
4
|
+
import android.view.LayoutInflater;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.NonNull;
|
|
9
|
+
import androidx.annotation.Nullable;
|
|
10
|
+
import androidx.fragment.app.Fragment;
|
|
11
|
+
|
|
12
|
+
import com.google.android.libraries.navigation.NavigationView;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Full-screen fragment that hosts the Google Navigation SDK's NavigationView.
|
|
16
|
+
* All lifecycle methods must be delegated to NavigationView — failing to do so
|
|
17
|
+
* results in a blank map or crash.
|
|
18
|
+
*/
|
|
19
|
+
public class NavigationFragment extends Fragment {
|
|
20
|
+
|
|
21
|
+
private NavigationView navigationView;
|
|
22
|
+
|
|
23
|
+
public static NavigationFragment newInstance() {
|
|
24
|
+
return new NavigationFragment();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Nullable
|
|
28
|
+
@Override
|
|
29
|
+
public View onCreateView(
|
|
30
|
+
@NonNull LayoutInflater inflater,
|
|
31
|
+
@Nullable ViewGroup container,
|
|
32
|
+
@Nullable Bundle savedInstanceState
|
|
33
|
+
) {
|
|
34
|
+
navigationView = new NavigationView(requireContext());
|
|
35
|
+
navigationView.onCreate(savedInstanceState);
|
|
36
|
+
return navigationView;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public void onStart() {
|
|
41
|
+
super.onStart();
|
|
42
|
+
if (navigationView != null) navigationView.onStart();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
public void onResume() {
|
|
47
|
+
super.onResume();
|
|
48
|
+
if (navigationView != null) navigationView.onResume();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public void onPause() {
|
|
53
|
+
if (navigationView != null) navigationView.onPause();
|
|
54
|
+
super.onPause();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public void onStop() {
|
|
59
|
+
if (navigationView != null) navigationView.onStop();
|
|
60
|
+
super.onStop();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
public void onDestroyView() {
|
|
65
|
+
if (navigationView != null) navigationView.onDestroy();
|
|
66
|
+
super.onDestroyView();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Override
|
|
70
|
+
public void onSaveInstanceState(@NonNull Bundle outState) {
|
|
71
|
+
super.onSaveInstanceState(outState);
|
|
72
|
+
if (navigationView != null) navigationView.onSaveInstanceState(outState);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "GoogleNavigationPlugin",
|
|
4
|
+
"slug": "googlenavigationplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "initialize",
|
|
10
|
+
"signature": "(options: { apiKey: string; }) => Promise<{ success: boolean; }>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "{ apiKey: string; }"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<{ success: boolean; }>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "Initialize the Navigation SDK with API key",
|
|
21
|
+
"complexTypes": [],
|
|
22
|
+
"slug": "initialize"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "startNavigation",
|
|
26
|
+
"signature": "(options: { destinationLatitude: number; destinationLongitude: number; travelMode?: 'DRIVING' | 'WALKING' | 'CYCLING' | 'TWO_WHEELER'; }) => Promise<{ success: boolean; }>",
|
|
27
|
+
"parameters": [
|
|
28
|
+
{
|
|
29
|
+
"name": "options",
|
|
30
|
+
"docs": "",
|
|
31
|
+
"type": "{ destinationLatitude: number; destinationLongitude: number; travelMode?: 'DRIVING' | 'WALKING' | 'CYCLING' | 'TWO_WHEELER' | undefined; }"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"returns": "Promise<{ success: boolean; }>",
|
|
35
|
+
"tags": [],
|
|
36
|
+
"docs": "Start navigation to a destination",
|
|
37
|
+
"complexTypes": [],
|
|
38
|
+
"slug": "startnavigation"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "stopNavigation",
|
|
42
|
+
"signature": "() => Promise<{ success: boolean; }>",
|
|
43
|
+
"parameters": [],
|
|
44
|
+
"returns": "Promise<{ success: boolean; }>",
|
|
45
|
+
"tags": [],
|
|
46
|
+
"docs": "Stop navigation",
|
|
47
|
+
"complexTypes": [],
|
|
48
|
+
"slug": "stopnavigation"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "showNavigationView",
|
|
52
|
+
"signature": "(options: { show: boolean; }) => Promise<{ success: boolean; }>",
|
|
53
|
+
"parameters": [
|
|
54
|
+
{
|
|
55
|
+
"name": "options",
|
|
56
|
+
"docs": "",
|
|
57
|
+
"type": "{ show: boolean; }"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"returns": "Promise<{ success: boolean; }>",
|
|
61
|
+
"tags": [],
|
|
62
|
+
"docs": "Show/hide navigation view",
|
|
63
|
+
"complexTypes": [],
|
|
64
|
+
"slug": "shownavigationview"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "addListener",
|
|
68
|
+
"signature": "(eventName: 'onArrival' | 'onRouteChanged' | 'onNavigationReady', listenerFunc: (event: any) => void) => Promise<PluginListenerHandle>",
|
|
69
|
+
"parameters": [
|
|
70
|
+
{
|
|
71
|
+
"name": "eventName",
|
|
72
|
+
"docs": "",
|
|
73
|
+
"type": "'onArrival' | 'onRouteChanged' | 'onNavigationReady'"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "listenerFunc",
|
|
77
|
+
"docs": "",
|
|
78
|
+
"type": "(event: any) => void"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
82
|
+
"tags": [],
|
|
83
|
+
"docs": "Add listener for navigation events",
|
|
84
|
+
"complexTypes": [
|
|
85
|
+
"PluginListenerHandle"
|
|
86
|
+
],
|
|
87
|
+
"slug": "addlisteneronarrival--onroutechanged--onnavigationready-"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "removeAllListeners",
|
|
91
|
+
"signature": "() => Promise<void>",
|
|
92
|
+
"parameters": [],
|
|
93
|
+
"returns": "Promise<void>",
|
|
94
|
+
"tags": [],
|
|
95
|
+
"docs": "Remove all listeners",
|
|
96
|
+
"complexTypes": [],
|
|
97
|
+
"slug": "removealllisteners"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"properties": []
|
|
101
|
+
},
|
|
102
|
+
"interfaces": [
|
|
103
|
+
{
|
|
104
|
+
"name": "PluginListenerHandle",
|
|
105
|
+
"slug": "pluginlistenerhandle",
|
|
106
|
+
"docs": "",
|
|
107
|
+
"tags": [],
|
|
108
|
+
"methods": [],
|
|
109
|
+
"properties": [
|
|
110
|
+
{
|
|
111
|
+
"name": "remove",
|
|
112
|
+
"tags": [],
|
|
113
|
+
"docs": "",
|
|
114
|
+
"complexTypes": [],
|
|
115
|
+
"type": "() => Promise<void>"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"enums": [],
|
|
121
|
+
"typeAliases": [],
|
|
122
|
+
"pluginConfigs": []
|
|
123
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface GoogleNavigationPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Initialize the Navigation SDK with API key
|
|
4
|
+
*/
|
|
5
|
+
initialize(options: {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Start navigation to a destination
|
|
12
|
+
*/
|
|
13
|
+
startNavigation(options: {
|
|
14
|
+
destinationLatitude: number;
|
|
15
|
+
destinationLongitude: number;
|
|
16
|
+
travelMode?: 'DRIVING' | 'WALKING' | 'CYCLING' | 'TWO_WHEELER';
|
|
17
|
+
}): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Stop navigation
|
|
22
|
+
*/
|
|
23
|
+
stopNavigation(): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Show/hide navigation view
|
|
28
|
+
*/
|
|
29
|
+
showNavigationView(options: {
|
|
30
|
+
show: boolean;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Add listener for navigation events
|
|
36
|
+
*/
|
|
37
|
+
addListener(eventName: 'onArrival' | 'onRouteChanged' | 'onNavigationReady', listenerFunc: (event: any) => void): Promise<PluginListenerHandle>;
|
|
38
|
+
/**
|
|
39
|
+
* Remove all listeners
|
|
40
|
+
*/
|
|
41
|
+
removeAllListeners(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export interface PluginListenerHandle {
|
|
44
|
+
remove: () => Promise<void>;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface GoogleNavigationPlugin {\n /**\n * Initialize the Navigation SDK with API key\n */\n initialize(options: { apiKey: string }): Promise<{ success: boolean }>;\n\n /**\n * Start navigation to a destination\n */\n startNavigation(options: {\n destinationLatitude: number;\n destinationLongitude: number;\n travelMode?: 'DRIVING' | 'WALKING' | 'CYCLING' | 'TWO_WHEELER';\n }): Promise<{ success: boolean }>;\n\n /**\n * Stop navigation\n */\n stopNavigation(): Promise<{ success: boolean }>;\n\n /**\n * Show/hide navigation view\n */\n showNavigationView(options: { show: boolean }): Promise<{ success: boolean }>;\n\n /**\n * Add listener for navigation events\n */\n addListener(\n eventName: 'onArrival' | 'onRouteChanged' | 'onNavigationReady',\n listenerFunc: (event: any) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners\n */\n removeAllListeners(): Promise<void>;\n}\n\nexport interface PluginListenerHandle {\n remove: () => Promise<void>;\n}"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const GoogleNavigation = registerPlugin('GoogleNavigation', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.GoogleNavigationWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { GoogleNavigation };
|
|
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,gBAAgB,GAAG,cAAc,CAAyB,kBAAkB,EAAE;IAClF,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;CACpE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { GoogleNavigationPlugin } from './definitions';\n\nconst GoogleNavigation = registerPlugin<GoogleNavigationPlugin>('GoogleNavigation', {\n web: () => import('./web').then((m) => new m.GoogleNavigationWeb()),\n});\n\nexport * from './definitions';\nexport { GoogleNavigation };\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { GoogleNavigationPlugin } from './definitions';
|
|
3
|
+
export declare class GoogleNavigationWeb extends WebPlugin implements GoogleNavigationPlugin {
|
|
4
|
+
initialize(_options: {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
startNavigation(_options: {
|
|
10
|
+
destinationLatitude: number;
|
|
11
|
+
destinationLongitude: number;
|
|
12
|
+
travelMode?: 'DRIVING' | 'WALKING' | 'CYCLING' | 'TWO_WHEELER';
|
|
13
|
+
}): Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
stopNavigation(): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
showNavigationView(_options: {
|
|
20
|
+
show: boolean;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
success: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class GoogleNavigationWeb extends WebPlugin {
|
|
3
|
+
async initialize(_options) {
|
|
4
|
+
throw this.unimplemented('Not available on web.');
|
|
5
|
+
}
|
|
6
|
+
async startNavigation(_options) {
|
|
7
|
+
throw this.unimplemented('Not available on web.');
|
|
8
|
+
}
|
|
9
|
+
async stopNavigation() {
|
|
10
|
+
throw this.unimplemented('Not available on web.');
|
|
11
|
+
}
|
|
12
|
+
async showNavigationView(_options) {
|
|
13
|
+
throw this.unimplemented('Not available on web.');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# 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;AAI5C,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,KAAK,CAAC,UAAU,CAAC,QAA4B;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,QAIrB;QACC,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA2B;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { GoogleNavigationPlugin } from './definitions';\n\nexport class GoogleNavigationWeb extends WebPlugin implements GoogleNavigationPlugin {\n async initialize(_options: { apiKey: string }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not available on web.');\n }\n\n async startNavigation(_options: {\n destinationLatitude: number;\n destinationLongitude: number;\n travelMode?: 'DRIVING' | 'WALKING' | 'CYCLING' | 'TWO_WHEELER';\n }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not available on web.');\n }\n\n async stopNavigation(): Promise<{ success: boolean }> {\n throw this.unimplemented('Not available on web.');\n }\n\n async showNavigationView(_options: { show: boolean }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not available on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const GoogleNavigation = core.registerPlugin('GoogleNavigation', {
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.GoogleNavigationWeb()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
class GoogleNavigationWeb extends core.WebPlugin {
|
|
10
|
+
async initialize(_options) {
|
|
11
|
+
throw this.unimplemented('Not available on web.');
|
|
12
|
+
}
|
|
13
|
+
async startNavigation(_options) {
|
|
14
|
+
throw this.unimplemented('Not available on web.');
|
|
15
|
+
}
|
|
16
|
+
async stopNavigation() {
|
|
17
|
+
throw this.unimplemented('Not available on web.');
|
|
18
|
+
}
|
|
19
|
+
async showNavigationView(_options) {
|
|
20
|
+
throw this.unimplemented('Not available on web.');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
25
|
+
__proto__: null,
|
|
26
|
+
GoogleNavigationWeb: GoogleNavigationWeb
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.GoogleNavigation = GoogleNavigation;
|
|
30
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst GoogleNavigation = registerPlugin('GoogleNavigation', {\n web: () => import('./web').then((m) => new m.GoogleNavigationWeb()),\n});\nexport * from './definitions';\nexport { GoogleNavigation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class GoogleNavigationWeb extends WebPlugin {\n async initialize(_options) {\n throw this.unimplemented('Not available on web.');\n }\n async startNavigation(_options) {\n throw this.unimplemented('Not available on web.');\n }\n async stopNavigation() {\n throw this.unimplemented('Not available on web.');\n }\n async showNavigationView(_options) {\n throw this.unimplemented('Not available on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvE,CAAC;;ACFM,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;AACzD,IAAI;AACJ,IAAI,MAAM,eAAe,CAAC,QAAQ,EAAE;AACpC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;AACzD,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;AACzD,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;AACzD,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var capacitorGoogleNavigation = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const GoogleNavigation = core.registerPlugin('GoogleNavigation', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.GoogleNavigationWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class GoogleNavigationWeb extends core.WebPlugin {
|
|
9
|
+
async initialize(_options) {
|
|
10
|
+
throw this.unimplemented('Not available on web.');
|
|
11
|
+
}
|
|
12
|
+
async startNavigation(_options) {
|
|
13
|
+
throw this.unimplemented('Not available on web.');
|
|
14
|
+
}
|
|
15
|
+
async stopNavigation() {
|
|
16
|
+
throw this.unimplemented('Not available on web.');
|
|
17
|
+
}
|
|
18
|
+
async showNavigationView(_options) {
|
|
19
|
+
throw this.unimplemented('Not available on web.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
24
|
+
__proto__: null,
|
|
25
|
+
GoogleNavigationWeb: GoogleNavigationWeb
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
exports.GoogleNavigation = GoogleNavigation;
|
|
29
|
+
|
|
30
|
+
return exports;
|
|
31
|
+
|
|
32
|
+
})({}, capacitorExports);
|
|
33
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst GoogleNavigation = registerPlugin('GoogleNavigation', {\n web: () => import('./web').then((m) => new m.GoogleNavigationWeb()),\n});\nexport * from './definitions';\nexport { GoogleNavigation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class GoogleNavigationWeb extends WebPlugin {\n async initialize(_options) {\n throw this.unimplemented('Not available on web.');\n }\n async startNavigation(_options) {\n throw this.unimplemented('Not available on web.');\n }\n async stopNavigation() {\n throw this.unimplemented('Not available on web.');\n }\n async showNavigationView(_options) {\n throw this.unimplemented('Not available on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICFM,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;IACzD,IAAI;IACJ,IAAI,MAAM,eAAe,CAAC,QAAQ,EAAE;IACpC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;IACzD,IAAI;IACJ,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;IACzD,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;IACzD,IAAI;IACJ;;;;;;;;;;;;;;;"}
|