希望有人可以帮助我,我试图用缩放和居中显示两个方向点,所以我可以只显示 2 个点而不是所有地图!看来变焦不起作用。
这是我的代码
var map;
function initialize(){
var mapOptions = {
zoom: 14,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var request = {
origin:"Mexico",
destination:"Montreal",
travelMode: google.maps.TravelMode.DRIVING
};
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
// Indicamos dónde esta el mapa para renderizarnos
directionsDisplay.setMap(map);
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
提前致谢