Exemple #1
0
    /// <summary>
    /// Creates a new request for a route search.
    /// </summary>
    /// <param name="start">Coordinates of the route begins.</param>
    /// <param name="end">Coordinates of the route ends.</param>
    /// <param name="lang">Language of intructions.</param>
    /// <param name="pref">The preference of the routing.</param>
    /// <param name="noMotorways">No Motorways.</param>
    /// <param name="noTollways">No Tollways.</param>
    /// <param name="via">Coordinates of the via positions.</param>
    /// <returns>Query instance.</returns>
    public static OnlineMapsOpenRouteService Find(Vector2 start, Vector2 end, string lang, OnlineMapsOpenRouteServicePref pref = OnlineMapsOpenRouteServicePref.Fastest, bool noMotorways = false, bool noTollways = false, Vector2[] via = null)
    {
        OnlineMapsOpenRouteService query = new OnlineMapsOpenRouteService(start, end, lang, pref, noMotorways, noTollways, via);

        OnlineMaps.instance.AddGoogleAPIQuery(query);
        return(query);
    }
 private void Start()
 {
     // Looking for pedestrian route between the coordinates.
     OnlineMapsOpenRouteService.Directions(
         new OnlineMapsOpenRouteService.DirectionParams(key,
                                                        new []
     {
         // Coordinates
         new OnlineMapsVector2d(8.6817521f, 49.4173462f),
         new OnlineMapsVector2d(8.6828883f, 49.4067577f)
     })
     {
         // Extra params
         language = "ru",
         profile  = OnlineMapsOpenRouteService.DirectionParams.Profile.footWalking
     }).OnComplete += OnRequestComplete;
 }
        private void Start()
        {
            // Looking for pedestrian route between the coordinates.
            OnlineMapsOpenRouteService.Directions(
                new OnlineMapsOpenRouteService.DirectionParams(key,
                                                               new []
            {
                // Coordinates
//                        new OnlineMapsVector2d(8.6817521f, 49.4173462f),
//                        new OnlineMapsVector2d(8.6828883f, 49.4067577f)  //default
                new OnlineMapsVector2d(114.407878420738f, 30.510284051858f),
                new OnlineMapsVector2d(114.421482327989f, 30.5164690022613f)
            })
            {
                // Extra params
                language = "ru",
                profile  = OnlineMapsOpenRouteService.DirectionParams.Profile.footWalking
            }).OnComplete += OnRequestComplete;
        }
        /// <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];
        }
 public void hustRoute()
 {
     if (OnlineMapsLocationService.instance.position != Vector2.zero)
     {
         OnlineMapsOpenRouteService.Directions(
             new OnlineMapsOpenRouteService.DirectionParams(key,
                                                            new []
         {
             // Coordinates
             //                        new OnlineMapsVector2d(8.6817521f, 49.4173462f),
             //                        new OnlineMapsVector2d(8.6828883f, 49.4067577f)  //default
             new OnlineMapsVector2d(OnlineMapsLocationService.instance.position.x, OnlineMapsLocationService.instance.position.y),
             new OnlineMapsVector2d(hustMarker.position.x, hustMarker.position.y)
         })
         {
             // Extra params
             language = "en",
             //profile = OnlineMapsOpenRouteService.DirectionParams.Profile.footWalking
             profile = (hustWalkingFoot)?(OnlineMapsOpenRouteService.DirectionParams.Profile.footWalking):(OnlineMapsOpenRouteService.DirectionParams.Profile.drivingCar)
         }).OnComplete += OnRequestComplete;
     }
 }
    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];
        }
    }
Exemple #8
0
 private void Start()
 {
     // Looking for pedestrian route between the coordinates.
     OnlineMapsOpenRouteService.Find(new Vector2(8.6817521f, 49.4173462f), new Vector2(8.6828883f, 49.4067577f), "ru", OnlineMapsOpenRouteService.OnlineMapsOpenRouteServicePref.Pedestrian).OnComplete += OnRequestComplete;
 }
 /// <summary>
 /// Creates a new request for a route search.
 /// </summary>
 /// <param name="start">Coordinates of the route begins.</param>
 /// <param name="end">Coordinates of the route ends.</param>
 /// <param name="lang">Language of intructions.</param>
 /// <param name="pref">The preference of the routing.</param>
 /// <param name="noMotorways">No Motorways.</param>
 /// <param name="noTollways">No Tollways.</param>
 /// <param name="via">Coordinates of the via positions.</param>
 /// <returns>Query instance.</returns>
 public static OnlineMapsOpenRouteService Find(Vector2 start, Vector2 end, string lang, OnlineMapsOpenRouteServicePref pref = OnlineMapsOpenRouteServicePref.Fastest, bool noMotorways = false, bool noTollways = false, Vector2[] via = null)
 {
     OnlineMapsOpenRouteService query = new OnlineMapsOpenRouteService(start, end, lang, pref, noMotorways, noTollways, via);
     OnlineMaps.instance.AddGoogleAPIQuery(query);
     return query;
 }