void validateAndPerformGoogleRoute(String routeStart, String routeEnd) { String URL = "http://www.mapquestapi.com/directions/v2/"; String query = "route?key=YOUR_KEY_HERE&"; String dest = "from=" + routeEnd; String orgin = "&to=" + routeStart + "&callback=renderNarrative"; final GsonGetRequest<RouteObject> gsonGetRequest = RouteRequests.getRouteObject( new Response.Listener<RouteObject>() { @Override public void onResponse(RouteObject routeObject) { // Deal with the RouteObject here String results = setRouteData(routeObject); try { callback.returnResults(results); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse( routeObject.getTitle(), stepNumber, stepDirections, startPoint, endPoint, distance, duration)); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { try { callback.returnResults("Network or transmission error has occurred."); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse("Network or transmission error has occurred.", "Empty")); } catch (Exception e) { e.printStackTrace(); } } }, orgin, dest, URL, query); App.addRequest(gsonGetRequest, TAG); }
void validateAndPerformOsmRoute(String routeStart, String routeEnd) { String URL = "http://router.project-osrm.org/viaroute?"; String query = ""; String dest = routeEnd; String orgin = routeStart; final GsonGetRequest<RouteObject> gsonGetRequest = RouteRequests.getOsmRoute( new Response.Listener<RouteObject>() { @Override public void onResponse(RouteObject routeObject) { // Deal with the RouteObject here String results = setRouteData(routeObject); try { callback.returnResults(results); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse( routeObject.getTitle(), stepNumber, stepDirections, startPoint, endPoint, distance, duration)); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { try { callback.returnResults("Network or transmission error has occurred."); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse("Network or transmission error has occurred.", "Empty")); } catch (Exception e) { e.printStackTrace(); } } }, orgin, dest, URL, query); App.addRequest(gsonGetRequest, TAG); }