/// <summary> /// This method is called when a response is received. /// </summary> /// <param name="response">Response string</param> private void OnRequestComplete(string response) { Debug.Log(response); // Get the route steps. //List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParseORS(response); tesla = OnlineMapsOpenRouteService.GetDirectionResults(response); // Get the route points. tesla2 = tesla.routes; Debug.Log(tesla.routes.Length); List <OnlineMapsVector2d> points = tesla2[0].points; // Draw the route. //OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(points, Color.red)); OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(points, Color.red, 5)); // Set the map position to the first point of route. OnlineMaps.instance.position = points[0]; }
/// <summary> /// This method is called when a response is received. /// </summary> /// <param name="response">Response string</param> private void OnRequestComplete(string response) { Debug.Log(response); OnlineMapsOpenRouteServiceDirectionResult result = OnlineMapsOpenRouteService.GetDirectionResults(response); if (result == null || result.routes.Length == 0) { Debug.Log("Open Route Service Directions failed."); return; } // Get the points of the first route. List <OnlineMapsVector2d> points = result.routes[0].points; // Draw the route. OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(points, Color.red)); // Set the map position to the first point of route. OnlineMaps.instance.position = points[0]; }
private void OnRequestComplete(string response) { Debug.Log(response); if (hustDrawLine != null) { OnlineMaps.instance.RemoveDrawingElement(hustDrawLine); } // Get the route steps. //List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParseORS(response); hustTesla = OnlineMapsOpenRouteService.GetDirectionResults(response); // Get the route points. if (hustTesla == null) { //let the user know there has been an error with open route service*********************** Debug.Log("gods are not merciful"); return; //make user know there is an error******************* } hustTesla2 = hustTesla.routes; Debug.Log(hustTesla.routes.Length); for (int i = 0; i < hustTesla.routes.Length; i++) { List <OnlineMapsVector2d> points = hustTesla2 [i].points; hustDrawLine = new OnlineMapsDrawingLine(points, Color.red, 5); // Draw the route. //OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(points, Color.red)); OnlineMaps.instance.AddDrawingElement(hustDrawLine); // Set the map position to the first point of route. OnlineMaps.instance.position = points [0]; } }