capacitor-google-navigation 0.0.9 → 0.1.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.
|
@@ -59,18 +59,12 @@ public class GoogleNavigation {
|
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
Waypoint destination
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.setTitle("Destination")
|
|
67
|
-
.build();
|
|
68
|
-
} catch (Waypoint.UnsupportedTravelModeException e) {
|
|
69
|
-
callback.onResult(false, "Unsupported travel mode");
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
62
|
+
Waypoint destination = new Waypoint.Builder()
|
|
63
|
+
.setLatLng(lat, lng)
|
|
64
|
+
.setTitle("Destination")
|
|
65
|
+
.build();
|
|
72
66
|
|
|
73
|
-
|
|
67
|
+
int mode;
|
|
74
68
|
switch (travelMode) {
|
|
75
69
|
case "WALKING": mode = RoutingOptions.TravelMode.WALKING; break;
|
|
76
70
|
case "CYCLING": mode = RoutingOptions.TravelMode.CYCLING; break;
|
|
@@ -78,23 +72,17 @@ public class GoogleNavigation {
|
|
|
78
72
|
default: mode = RoutingOptions.TravelMode.DRIVING; break;
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
RoutingOptions routingOptions = new RoutingOptions.
|
|
82
|
-
.travelMode(mode)
|
|
83
|
-
.build();
|
|
75
|
+
RoutingOptions routingOptions = new RoutingOptions().travelMode(mode);
|
|
84
76
|
|
|
85
|
-
navigator.setDestination(destination, routingOptions
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} else {
|
|
93
|
-
callback.onResult(false, "Route error: " + status.name());
|
|
94
|
-
}
|
|
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());
|
|
95
84
|
}
|
|
96
|
-
}
|
|
97
|
-
);
|
|
85
|
+
});
|
|
98
86
|
}
|
|
99
87
|
|
|
100
88
|
public void stopNavigation() {
|
|
@@ -141,11 +129,12 @@ public class GoogleNavigation {
|
|
|
141
129
|
private void attachListeners() {
|
|
142
130
|
if (navigator == null) return;
|
|
143
131
|
|
|
144
|
-
navigator.addArrivalListener(
|
|
132
|
+
navigator.addArrivalListener(arrivalEvent -> {
|
|
133
|
+
Waypoint wp = arrivalEvent.getWaypoint();
|
|
145
134
|
JSObject data = new JSObject();
|
|
146
|
-
data.put("latitude",
|
|
147
|
-
data.put("longitude",
|
|
148
|
-
data.put("title",
|
|
135
|
+
data.put("latitude", wp.getPosition().latitude);
|
|
136
|
+
data.put("longitude", wp.getPosition().longitude);
|
|
137
|
+
data.put("title", wp.getTitle());
|
|
149
138
|
plugin.fireEvent("onArrival", data);
|
|
150
139
|
});
|
|
151
140
|
|