My google map centers around a route, that is given by a Direction Service and rendered by a Direction Renderer (called directionsDisplay here).
According to the docs and many threads and forums I've read, the infoWindow should autoPan to center at version 3.0 (which I am using).
I'm waiting till all callbacks are called, I have tried to open the window when gmaps tileloaded-Event is fired, as well as the idle event.
No matter what: The map centers always around the route (and hence pushing the infowindow out of the viewport).
What am I doing wrong here?
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
directionsDisplay.suppressMarkers = true;
if(this.marker){
this.marker.setPosition(result.routes[0].overview_path[result.routes[0].overview_path.length-1]);
} else{
this.marker = new google.maps.Marker({
position: result.routes[0].overview_path[result.routes[0].overview_path.length-1],
map: Gmap.map
});
}
var contentString = '<div id="infowindow_title">Hello World</div><div id="infowindow_cat">Lorem Ipsum</div>';
if(!this.infoWindow){
this.infoWindow = new google.maps.InfoWindow({
content: contentString
});
} else {
this.infowindow.setContent(contentString);
}
this.infoWindow.open(Gmap.map, this.marker);
}
});