-1
我使用Google地图指引API生成地图路线,并使用路线指向地点,但是如何使用JavaScript API获取实际文字路线?从Google地图指南API获取实际路线
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var mapOfDirections;
directionsDisplay = new google.maps.DirectionsRenderer();
var center = new google.maps.LatLng(lat, lon);
var mapOptions = {
zoom:6,
center: center
}
maps = new google.maps.Map(document.getElementById('main'), mapOptions);
directionsDisplay.setMap(maps);
var request = {
origin:from,
destination:to,
travelMode:google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(result, status){
if(status==google.maps.DirectionsStatus.OK) directionsDisplay.setDirections(result);
});
设置[上的DirectionsRenderer面板(https://developers.google.com/maps/documentation/javascript/reference#DirectionsRendererOptions) – geocodezip 2014-10-05 05:48:27