On Jan 28, 6:30 pm, henzhenry <mandy2...@gmail.com> wrote:
> Hello V3 team. In V3, I don't know how to set center after using
> DirectionsService to draw routes. But, in V2, I can use
> GEvent.addListener(gdir, "addoverlay",..... to set center again after
> drawing routes.
> How can I set center after using DirectionsService to draw routes?

DirectionsService provides a callback function. That is the second
parameter of route() method.
The callback function is used for calling DirectionsRenderer to draw
the trip by setDirections().

If you try to setCenter() simultaneously, DirectionsRenderer returns
later and overrides your center. DirectionsRenderer doesn't provide
any event or callback but you can construct a once-only event by:

  google.maps.event.addListenerOnce(map, 'idle', function(){
    map.setCenter(yourLatLng);
  });

Put that inside the callback function. It works quite like
'addoverlay' of v2 GDirections().

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api...@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to