capacitor-google-navigation 0.1.3 → 0.1.5
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.
|
@@ -7,6 +7,7 @@ import androidx.fragment.app.FragmentManager;
|
|
|
7
7
|
|
|
8
8
|
import com.getcapacitor.JSObject;
|
|
9
9
|
import com.getcapacitor.Logger;
|
|
10
|
+
import com.google.android.libraries.navigation.ArrivalEvent;
|
|
10
11
|
import com.google.android.libraries.navigation.NavigationApi;
|
|
11
12
|
import com.google.android.libraries.navigation.Navigator;
|
|
12
13
|
import com.google.android.libraries.navigation.Waypoint;
|
|
@@ -61,7 +62,7 @@ public class GoogleNavigation {
|
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
Waypoint destination = Waypoint.
|
|
65
|
+
Waypoint destination = new Waypoint.Builder()
|
|
65
66
|
.setLatLng(lat, lng)
|
|
66
67
|
.setTitle("Destination")
|
|
67
68
|
.build();
|
|
@@ -69,17 +70,15 @@ public class GoogleNavigation {
|
|
|
69
70
|
List<Waypoint> destinations = new ArrayList<>();
|
|
70
71
|
destinations.add(destination);
|
|
71
72
|
|
|
72
|
-
navigator.setDestinations(destinations
|
|
73
|
-
|
|
74
|
-
public void onRouteStatusResult(Navigator.RouteStatus status) {
|
|
73
|
+
navigator.setDestinations(destinations)
|
|
74
|
+
.setOnResultListener(status -> {
|
|
75
75
|
if (status == Navigator.RouteStatus.OK) {
|
|
76
76
|
navigator.startGuidance();
|
|
77
77
|
callback.onResult(true, null);
|
|
78
78
|
} else {
|
|
79
79
|
callback.onResult(false, "Route error: " + status.name());
|
|
80
80
|
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
81
|
+
});
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
public void stopNavigation() {
|
|
@@ -128,7 +127,7 @@ public class GoogleNavigation {
|
|
|
128
127
|
|
|
129
128
|
navigator.addArrivalListener(new Navigator.ArrivalListener() {
|
|
130
129
|
@Override
|
|
131
|
-
public void onArrival(
|
|
130
|
+
public void onArrival(ArrivalEvent arrivalEvent) {
|
|
132
131
|
Waypoint wp = arrivalEvent.getWaypoint();
|
|
133
132
|
JSObject data = new JSObject();
|
|
134
133
|
data.put("latitude", wp.getPosition().latitude);
|