当嵌入到 jQuery Mobile“页面”中时,Google 地图会超出页面边缘。
我正在开发一个小型地图应用程序,它将 Google 地图嵌入到 jQuery Mobile“页面”中。我希望地图占据屏幕的整个水平宽度,但仅此而已。我遇到的问题是地图“溢出”了右侧页面的边缘,大约有 5% 左右。这可以在 http://www.codeemporium.com/experiments/map6.html (抱歉,目前还不会在 Firefox 中显示)您会注意到,地图右下角通常显示“使用条款”的位置已被切断。我正在使用的主 jQuery Mobile“页面”的 HTML 代码摘录如下(如上述页面的源代码所示):`
<div data-role="page" style="width:100%; height:100%;" id="main_page">
<div data-role="content" id="map_canvas" style="width:100%;height:80%;">
</div>
<div data-role="footer" style="width:100%;height:20%;">
<div data-role="navbar">
<ul>
<li><a href="#welcome" data-icon="info" data-iconpos="notext"></a></li>
<li><a href="#settings" data-icon="gear" data-iconpos="notext"></a></li>
<li><a href="#tracking" data-icon="alert" data-iconpos="notext"></a></li>
<li><a href="#search" data-icon="search" data-iconpos="notext"></a></li>
</ul>
</div><!-- /navbar -->
</div>
`
地图被注入到 map_canvas
div 中。在我的机器上使用 Chrome 开发人员,我可以看到地图画布最终宽度为 1295 像素,这比我的屏幕减去滚动条等的 1280 像素分辨率稍大一些。我遇到的问题是,我在解决我想象的样式问题方面几乎没有经验,甚至可能与上面的代码片段不直接相关。除了这个问题的具体解决方案之外,如果有人能建议如何以某种有条不紊的方式调试这些事情,我们也将不胜感激。
I have a small mapping application I'm working on that embeds a Google Map inside of a jQuery Mobile "page". I want the map to take up the full horizontal width of the screen, but no more. The problem I am having is that the map "overflows" off the edge of the page on the right hand side, by maybe 5%-ish. This can be seen at http://www.codeemporium.com/experiments/map6.html (sorry, won't show in Firefox just yet) where you will notice that in the bottom right hand corner where the map normally says "Terms of Use", it has been cut off. The HTML code excerpt for the main jQuery Mobile "page" I'm using is as follows (as can be seen in the aforementioned page's source code):`
<div data-role="page" style="width:100%; height:100%;" id="main_page">
<div data-role="content" id="map_canvas" style="width:100%;height:80%;">
</div>
<div data-role="footer" style="width:100%;height:20%;">
<div data-role="navbar">
<ul>
<li><a href="#welcome" data-icon="info" data-iconpos="notext"></a></li>
<li><a href="#settings" data-icon="gear" data-iconpos="notext"></a></li>
<li><a href="#tracking" data-icon="alert" data-iconpos="notext"></a></li>
<li><a href="#search" data-icon="search" data-iconpos="notext"></a></li>
</ul>
</div><!-- /navbar -->
</div>
`
The map is being injected into the map_canvas
div. Using the Chrome developer on my machine I can see that the map canvas ends up being 1295 pixels wide, which is a tad larger than the 1280 pixel resolution of my screen minus scroll bar etcetera. The problem I am having is that I have very little experience in troubleshooting what I imagine here is a styling issue, and may not even pertain directly to the code snippet above. In addition to a specific solution to this problem, if someone could suggest how to go about debugging these kind of things in some kind of methodical manner, it would also be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我们遇到这个问题时,我们必须创建这个函数:
您可以在 $(document).ready() 或地图初始化中运行 resizeMap() 。
When we ran into this issue we had to make this function:
you can run resizeMap() in $(document).ready() or in your map initialization.