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
- 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
- }
62
+ Waypoint destination = new Waypoint.Builder()
63
+ .setLatLng(lat, lng)
64
+ .setTitle("Destination")
65
+ .build();
72
66
 
73
- RoutingOptions.TravelMode mode;
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.Builder()
82
- .travelMode(mode)
83
- .build();
75
+ RoutingOptions routingOptions = new RoutingOptions().travelMode(mode);
84
76
 
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
- }
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(waypoint -> {
132
+ navigator.addArrivalListener(arrivalEvent -> {
133
+ Waypoint wp = arrivalEvent.getWaypoint();
145
134
  JSObject data = new JSObject();
146
- data.put("latitude", waypoint.getPosition().latitude);
147
- data.put("longitude", waypoint.getPosition().longitude);
148
- data.put("title", waypoint.getTitle());
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-google-navigation",
3
- "version": "0.0.9",
3
+ "version": "0.1.1",
4
4
  "description": "Google maps turn by turn navigation for capcitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",