0

我正在使用以下代码生成路线,并且我想指定一个显式的起始位置,但它总是从我的位置返回由位置 API 提供的路线,而不是origin参数中指定的位置。位置 API 已被授予从站点的不同部分访问的权限,因此不能简单地禁用它。

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) {
    //...
}

我考虑过指定sensor=falsesensor不是DirectionsRequest 对象的有效属性。

如何让 DirectionsService 兑现我指定的原点?

4

0 回答 0