0

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);


        }
    });
shredding
  • 5,374
  • 3
  • 46
  • 77
  • I can't see anything wrong here. It might help if you make a demo to play with. http://jsfiddle.net – Gareth Apr 20 '12 at 00:38

1 Answers1

0

I have found the error: gMaps did everything right; there was some css (in the theme of the cms i was using), that set some layer in the stack to overflow: hidden.

Thus, gMaps thought it had more space to show the infoWindow than it was acutally visible.

shredding
  • 5,374
  • 3
  • 46
  • 77