Can you disable the sensor when using the Google DirectionsService to generate a route?

119 Views Asked by At

I'm using the following code to generate a route and I want to specify an explicit starting position but it always returns a route from my location provided by the location API rather than the location specified in the origin parameter. The location API has been granted access from a different part of the site, so simply disabling it is not an option.

var current_position= new google.maps.LatLng(...);
var request = {
    origin: current_position,
    destination: to,
    travelMode: google.maps.TravelMode.DRIVING,
    unitSystem: google.maps.UnitSystem.IMPERIAL
};

var directionsService = new google.maps.DirectionsService();
directionsService.route(request, function(data, status) {
    //...
}

I thought about specifying sensor=false but sensor isn't a valid property of the DirectionsRequest object.

How can I get the DirectionsService to honour the origin I specify?

0

There are 0 best solutions below