gmaps-api-net icon indicating copy to clipboard operation
gmaps-api-net copied to clipboard

Getting ServiceResponseStatus.ZeroResults on DistanceMatrixService().GetResponse

Open martinezjm opened this issue 8 years ago • 2 comments

Can someone help me? My application was working fine, then all of a sudden I started getting ServiceResponseStatus.ZeroResults from the API call DistanceMatrixService().GetResponse. Is there a maximum call on the API? When does it reset?

Thank you.

Here is the code:

    private MapResponse GetTime(Waypoint startPoint, Waypoint endPoint)
    {
        try
        {
            SortedList<int, Waypoint> origin = new SortedList<int, Waypoint>();
            SortedList<int, Waypoint> destination = new SortedList<int, Waypoint>();

            origin.Add(0, startPoint);
            destination.Add(0, endPoint);

            DistanceMatrixRequest distanceRequest = new DistanceMatrixRequest()
            {
                Units = Units.imperial,
                WaypointsOrigin = origin,
                WaypointsDestination = destination,
                Sensor = false

            };

            DistanceMatrixResponse response = new DistanceMatrixService().GetResponse(distanceRequest);

            var mr = new MapResponse(); //Custom class to hold values

if (response.Rows[0].Elements[0].Status.Equals(ServiceResponseStatus.ZeroResults)) mr.Miles = 0; else {

                mr.Duration = response.Rows[0].Elements[0].duration.Text;
                mr.Miles = Convert.ToInt32(response.Rows[0].Elements[0].distance.Text);
                mr.TotalSeconds = Convert.ToInt32(response.Rows[0].Elements[0].duration.Value);

            }

            return mr;
        }
        catch (Exception ex)
        {
            throw new Exception("GetTime(): " + ex.Message);
        }

martinezjm avatar Jun 28 '16 18:06 martinezjm

I only know of a rate limiter by Google that limits calls to something like 20 per minute over a 15 minute period for anonymous api calls, without setting a key into the signing areas of the library.

Dont quote me on that but realistically you should be seeing OVER_RATE_LIMIT response if that were the case.

On Tue, Jun 28, 2016 at 2:33 PM, martinezjm [email protected] wrote:

Can someone help me? My application was working fine, then all of a sudden I started getting ServiceResponseStatus.ZeroResults from the API call DistanceMatrixService().GetResponse. Is there a maximum call on the API? When does it reset?

Thank you.

Here is the code:

private MapResponse GetTime(Waypoint startPoint, Waypoint endPoint)
{
    try
    {
        SortedList<int, Waypoint> origin = new SortedList<int, Waypoint>();
        SortedList<int, Waypoint> destination = new SortedList<int, Waypoint>();

        origin.Add(0, startPoint);
        destination.Add(0, endPoint);

        DistanceMatrixRequest distanceRequest = new DistanceMatrixRequest()
        {
            Units = Units.imperial,
            WaypointsOrigin = origin,
            WaypointsDestination = destination,
            Sensor = false

        };

        DistanceMatrixResponse response = new DistanceMatrixService().GetResponse(distanceRequest);

        var mr = new MapResponse(); //Custom class to hold values

if (response.Rows[0].Elements[0].Status.Equals(ServiceResponseStatus.ZeroResults)) mr.Miles = 0; else {

            mr.Duration = response.Rows[0].Elements[0].duration.Text;
            mr.Miles = Convert.ToInt32(response.Rows[0].Elements[0].distance.Text);
            mr.TotalSeconds = Convert.ToInt32(response.Rows[0].Elements[0].duration.Value);

        }

        return mr;
    }
    catch (Exception ex)
    {
        throw new Exception("GetTime(): " + ex.Message);
    }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ericnewton76/gmaps-api-net/issues/52, or mute the thread https://github.com/notifications/unsubscribe/ACG_zPIvwPLRHVe3MOylaJPSumd2K_hLks5qQWjcgaJpZM4JAZfK .

ericnewton76 avatar Jun 28 '16 20:06 ericnewton76

@martinezjm did you find some resolution on this issue? should we close or is it still a problem?

ericnewton76 avatar Jul 13 '17 22:07 ericnewton76