Topic: Search a route between two locations does not return routes

Hi
I am trying to create direction using to two GPS locations. I referred this FindDirectionExample example

However when I change GPS points it returns no routes.  I confirmed that API is working and both locations are reachable. When I use the same API and tested in https request in browser it shows steps and routes.


Please help. Thank you

Re: Search a route between two locations does not return routes

Hi.

Please show your code (without keys) and the coordinates you are using.
I will check it.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Search a route between two locations does not return routes

public void FindDirection()
    {
        //OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections
        //   (
        //       googleAPIKey,
        //       "Los Angeles", // FROM (string or Vector2)
        //       new Vector2(-118.178960f, 35.063995f) // TO (string or Vector2)
        //   );

        OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(googleAPIKey, origin, destination);
        request.OnComplete += OnFindDirectionComplete;
        request.Send();
    }

    private void OnFindDirectionComplete(string response)
    {
       
        OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);
        if (result == null || result.routes.Length == 0)
        {
            Debug.Log("Find direction failed");
            Debug.Log(response);
            return;
        }

        foreach (OnlineMapsGoogleDirectionsResult.Leg leg in result.routes[0].legs)
        {
            foreach (OnlineMapsGoogleDirectionsResult.Step step in leg.steps)
            {
                Debug.Log(step.string_instructions);
            }
        }
        OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(result.routes[0].overview_polylineD, Color.green);
        OnlineMaps.drawingElementManager.Add(route);
    }

Coordinates
Origin - 51.3260028,-0.7753541
Destination - 51.3363296,-0.775708

Re: Search a route between two locations does not return routes

Please make sure the values are in order.
In Online Maps API, longitude always comes first, then latitude.
If you use Vector2, X is longitude, Y is latitude.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

5 (edited by kiran.jodhani 2024-04-04 11:04:52)

Re: Search a route between two locations does not return routes

Oh thanks for the help
After changing values I was able to see routes and line