jquery 移动版中的谷歌地图
当在 jquery mobile 中显示 google 地图时(阅读论坛后),需要如下代码:
<div data-role="page" data-theme="b" class="page-map" style="width:100%; height:100%;">
<div data-role="header"><h1>Map Page</h1></div>
<div data-role="content" style="width:100%; height:100%; padding:0;">
<div id="map_canvas" style="width:100%; height:100%;"></div>
</div>
</div>
去掉外部 div 上的高度会导致 div 下降到高度 0 并且地图不会显示。我希望在地图下方获得一些动态文本(基于地图上的内容),其长度我不知道,所以我无法设置绝对高度。有人有解决这个问题的方法吗?
When showing a google map in jquery mobile it appears (after reading the forums) that code like the following is required:
<div data-role="page" data-theme="b" class="page-map" style="width:100%; height:100%;">
<div data-role="header"><h1>Map Page</h1></div>
<div data-role="content" style="width:100%; height:100%; padding:0;">
<div id="map_canvas" style="width:100%; height:100%;"></div>
</div>
</div>
Taking away the height on outside div causes the div to drop to height 0 and the map not being displayed. I was hoping to get some dynamic text below the map (based on the contents on the) which length I do not know so I can't set an absolute height. Has anyone got a workaround for this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这不是与 Google 地图相关的问题,问题是,您需要为地图画布设置特定的宽度和高度,您的代码可以重写为:
示例链接
更新:看看@Blowsie 评论,您还可以查看jquery-ui-map 插件。
This is not a Google maps related issue, the thing is, you need to SET a specific width and height for your Map canvas, your code could be rewritten like:
Example link
UPDATE: Have a look @Blowsie comment, you may also check the jquery-ui-map plugin.
这里有一个官方示例: http://view.jquerymobile .com/master/demos/examples/maps/geolocation.php
HTML:
CSS:
There is an official example for this here: http://view.jquerymobile.com/master/demos/examples/maps/geolocation.php
HTML:
CSS:
好吧,这就是我是如何做到的并且它对我有用。
然后将它们添加到您的 CSS 文件中。
这对我来说非常有效。
Well here how I did it and it worked for me.
Then add these to your CSS File.
This is working perfectly for me.
对我有用的快速而肮脏的修复:
Quick and dirty fix that worked for me: