问题描述
过去我在很多网站上都使用过Google地图,但是我遇到过一个我以前从未遇到过的问题。地图窗口正在显示,但它只显示左上方的地图片段,之后的任何内容(即使我在左右导航时),没有任何内容加载到右侧。它就好像被导航的窗口有一个内部偏移量,它将它从视口的侧面推开。有人知道可能是什么原因造成的吗?
编辑
发现当窗口被调整大小时,地图刷新,并且布局是固定的。
地图包含在通过javascript显示的标签中(并且通过显示:无
)。 tab容器是通过ajax加载的,加载时会调用loadMap函数。我试图通过将它包含在setTimeout函数中来推迟loadMap函数,该函数将地图的创建时间延迟1秒,但它仍然保持不变(需要调整窗口的大小以修复它)。
I have used Google Maps on many websites in the past, but I have been posed with an issue I haven't experienced before. The maps window is showing, but it's only showing maps segments from the top left, and anything after that (even when i'm navigating around), nothing loads to the right. Its as if the window that is navigated around has an internal offset that is pushing it off the side of the viewport. Does anyone know what could be causing it?
EDIT
I have just discovered that when the window is resized, the map refreshes, and the layout is fixed.
The map is contained within a tab that is shown via javascript (and hidden via display:none
). The tab container is loaded via ajax, and when it loads, the loadMap function is called. I tried postponing the loadMap function by enclosing it within a setTimeout function that delays the creation of the map by 1 second, but it still does the same (requiring the window to be resized to fix it)
Righto, I am not sure why it's not working, but I have changed my code to only execute the map creation function when the tab is first opened. That makes it work correctly
这篇关于Google地图窗口只显示部分地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!