我试图设置这些变量(to,from和mode),而不是让用户输入它们。我错过了什么步骤?
var from = (40.750484, -111.811177);
var to = (40.775041, -111.718560);
var mode = driving;
//$('#directions-form').submit(function(e) {
//$('#error').hide();
ds.route({
origin: from,
destination: to,
travelMode: mode
}, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
fitBounds = true;
dr.setDirections(result);
}
else {
$('#error').text(status).show();
}
recalcHeight();
});
e.preventDefault();
return false;
});
ds.route(from,to,mode);
答案 0 :(得分:1)
尝试......
var from = new google.maps.LatLng(40.750484, -111.811177);
var to = new google.maps.LatLng(40.775041, -111.718560);
var mode = google.maps.TravelMode.DRIVING;
旅行模式文档中包含更多模式示例... https://developers.google.com/maps/documentation/javascript/directions#TravelModes