繁体   English   中英

中心窗口位于信息窗口,而不是Google地图中的路线

[英]Center map at infowindow, not at route in google maps

我的Google地图以路线为中心,该路线由Directions服务提供,并由Directions Renderer渲染(此处称为DirectionsDisplay)。

根据我读过的文档以及许多主题和论坛,infoWindow应该自动以3.0版(我正在使用)为中心。

我一直等到所有回调都被调用为止,在gmaps tileloaded-Event以及idle事件被触发时,我试图打开窗口。

无论如何:地图始终以路线为中心(因此将信息窗口推出视口)。

我在这里做错了什么?

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


        }
    });

我发现了错误:gMaps所做的一切都正确; 有一些css(以我使用的cms为主题),将堆栈中的某些层设置为溢出:隐藏。

因此,gMaps认为它显示信息窗口的空间比实际可见的空间大。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM