문제

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.

다른 팁

I've replaced fitBounds with map.setZoom() , if i set preserveViewport as true, then my map is not visible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top