Yes.
Attach an event handler to the GDirections "load" event and in that
event handler read the polyline, get its bounds, and set the zoom
accordingly.

var polyline = dirObj.getPolyline();
var bounds = polyline.getBounds();
map.setCenter(bounds.getCenter(map), map.getBoundsZoomLevel(bounds));

As the "load" event is fired before the results are loaded on the map,
you'll probably need to set preserveViewport:true as well as
getPolyline:true in the GDirectionsOptions passet to the load() or
loadFromWaypoints() methods.
http://code.google.com/apis/maps/documentation/reference.html#GDirectionsOptions

--
Marcelo - http://maps.forum.nu
--



On Sep 11, 4:45 pm, dpoi <[email protected]> wrote:
> i wrote a simple function tracing mainly a route between two cities.
> The cities change according to parameters. The map always display in a
> simple 600px by 500px rectangle.
>
> Sometimes the start or end of the route is too near the boundary of
> the rectangle and the result is not pretty.
>
> Is there a simple way to solve this problem using setzoom, ...?
>
> Regards,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to