how to link up to Google Direction APi

htranhtran Member

hello
i need a route from current position to a point and to do that i need to deserialize a json response from an http request
i found and tested this tutorial code from internet:

public async Task<WayPoints> GetWayPointsAsync(string FromAddress, string ToAddress)
    {             
        var d = await GetClient<WayPoints>("directions/json?origin=" + FromAddress + "&destination=" + ToAddress);
        return d;
    }

But GetClient dont work
are there a different way to do that?
please help me
thanks in advance

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai
    edited June 2018

    @htran

    It looks like your url is incorrect:

    var d = await GetClient<WayPoints>("directions/json?origin=" + FromAddress + "&destination=" + ToAddress);
    

    "directions/json?origin=" ... will not get you to the directions API. I think it should be:

    var d = await GetClient<WayPoints>("https://maps.googleapis.com/maps/api/directions/json?origin=" + FromAddress + "&destination=" + ToAddress);
    
Sign In or Register to comment.