I am trying to over-ride Google Maps driving directions zoom. Yes, I have seen another question here on stackoverflow that is identical; however, that solution is not working for me.
Here is where I call a new DirectionsRenderer, and I define preserveViewport: true;
var dr = new google.maps.DirectionsRenderer({
map: map,
draggable: false,
preserveViewport: true
});
Here is where I call the routing service, and I define setOptions preserveviewport:true;
ds.route({
origin: from,
destination: to,
travelMode: mode
}, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
fitBounds = true;
dr.setOptions({ preserveViewport: true });
dr.setDirections(result);
}
});
However, this is not overriding the zoom functionality of directions service. Thoughts?
I solved this. Instead of calling map.fitbounds, I used map.setZoom. Fitbounds is to fit all the points on the screen, at the maximum zoom level. setZoom allows you to set your own zoom.