我使用 Google Maps API v3 显示从用户定义的起点到我的财产的路线。
除了端点的准确性之外,这在技术上工作正常。我已将我的财产的经度/纬度定义为准确的点,但方向仍会将您带到大约 100 米外的街道。
有没有办法强迫方向把你带到一个确切的点?
这是我的代码以防万一...
function getDirections(x, y) {
$("#directionsPanel").html("");
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
directionsDisplay.setPanel(document.getElementById('directionsPanel'));
directionsDisplay.setMap(map);
var request = {
origin: x,
destination: $('.lat').text() + ',' + $('.lng').text() ,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL,
provideRouteAlternatives: true,
region: "GB"
};
directionsService.route(request, function (response, status) {
directionsDisplay.setDirections(response);
$(".noValidRoute").hide();
});
}