On Nov 4, 10:27 am, Francesco <[EMAIL PROTECTED]> wrote:
> Hi!
> I'm working in local, so I can't report the link of my code. I try to
> search in other post, but I don't find what I'm searching for.
>
> I'm working with GDirections and I want to show two or more
> GDirections in the same map. I create two instance of GDirections (say
> gdir1 and gdir2) and I able to get the result, but the zoom is set to
> show only the last (dir2).
The second directions will always reset the map. If you use
{preserveViewport:true}, the second directions line won't recentre the
map. It will be left showing the first.
To include the second line as well, you need to get its extent:
var dir2sw=dir2.getBounds().getSouthWest();
var dir2ne=dir2.getBounds().getNorthEast();
and then add them to the first's bounding rectangle:
var dir1rect=dir1.getBounds();
dir1rect.extend(dir2sw);
dir1rect.extend(dir2ne);
and then use the result to set the map's centre and zoom:
map.setCenter(dir1rect.getCenter(),map.getBoundsZoomLevel(dir1rect));
All of that's untested. I might have tested it if you had included a
link to your map.
Andrew
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---