capacitor-google-navigation 0.1.0 → 0.1.2
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/android/build.gradle
CHANGED
|
@@ -52,7 +52,9 @@ dependencies {
|
|
|
52
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
53
|
implementation project(':capacitor-android')
|
|
54
54
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
-
implementation
|
|
55
|
+
implementation('com.google.android.libraries.navigation:navigation:6.0.0') {
|
|
56
|
+
exclude group: 'com.google.android.gms', module: 'play-services-maps'
|
|
57
|
+
}
|
|
56
58
|
testImplementation "junit:junit:$junitVersion"
|
|
57
59
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
60
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -64,7 +64,7 @@ public class GoogleNavigation {
|
|
|
64
64
|
.setTitle("Destination")
|
|
65
65
|
.build();
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
int mode;
|
|
68
68
|
switch (travelMode) {
|
|
69
69
|
case "WALKING": mode = RoutingOptions.TravelMode.WALKING; break;
|
|
70
70
|
case "CYCLING": mode = RoutingOptions.TravelMode.CYCLING; break;
|
|
@@ -72,23 +72,17 @@ public class GoogleNavigation {
|
|
|
72
72
|
default: mode = RoutingOptions.TravelMode.DRIVING; break;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
RoutingOptions routingOptions = new RoutingOptions.
|
|
76
|
-
.travelMode(mode)
|
|
77
|
-
.build();
|
|
75
|
+
RoutingOptions routingOptions = new RoutingOptions().travelMode(mode);
|
|
78
76
|
|
|
79
|
-
navigator.setDestination(destination, routingOptions
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
callback.onResult(false, "Route error: " + status.name());
|
|
88
|
-
}
|
|
77
|
+
navigator.setDestination(destination, routingOptions)
|
|
78
|
+
.setOnResultListener(status -> {
|
|
79
|
+
if (status == Navigator.RouteStatus.OK) {
|
|
80
|
+
navigator.startGuidance();
|
|
81
|
+
callback.onResult(true, null);
|
|
82
|
+
} else {
|
|
83
|
+
callback.onResult(false, "Route error: " + status.name());
|
|
89
84
|
}
|
|
90
|
-
}
|
|
91
|
-
);
|
|
85
|
+
});
|
|
92
86
|
}
|
|
93
87
|
|
|
94
88
|
public void stopNavigation() {
|
|
@@ -135,11 +129,12 @@ public class GoogleNavigation {
|
|
|
135
129
|
private void attachListeners() {
|
|
136
130
|
if (navigator == null) return;
|
|
137
131
|
|
|
138
|
-
navigator.addArrivalListener(
|
|
132
|
+
navigator.addArrivalListener(arrivalEvent -> {
|
|
133
|
+
Waypoint wp = arrivalEvent.getWaypoint();
|
|
139
134
|
JSObject data = new JSObject();
|
|
140
|
-
data.put("latitude",
|
|
141
|
-
data.put("longitude",
|
|
142
|
-
data.put("title",
|
|
135
|
+
data.put("latitude", wp.getPosition().latitude);
|
|
136
|
+
data.put("longitude", wp.getPosition().longitude);
|
|
137
|
+
data.put("title", wp.getTitle());
|
|
143
138
|
plugin.fireEvent("onArrival", data);
|
|
144
139
|
});
|
|
145
140
|
|