jquery - 如何使用 jQuery Mobile 显示全屏谷歌地图?

标签 jquery google-maps jquery-mobile google-maps-api-3

以下代码显示奇怪的输出。我应该看到全屏移动 map 。但由于某种原因,它仅显示在屏幕的一部分上。我正在使用 jquery.ui.map 进行映射。

<!DOCTYPE html> 
<html> 
    <head> 
    <title>My Page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" />
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
    <script src="js/jquery-1.7.1.min.js"></script>
    <script src="js/jquery.mobile-1.1.0.min.js"></script>
    <script type="text/javascript" src="js/jquery.ui.map.min.js"></script>
</head> 
<body> 

<div data-role="page">

    <div data-role="header">
        <h1>My Title</h1>
    </div><!-- /header -->

    <div data-role="content" id="map_canvas"  name="contentMain">   

    </div><!-- /content -->

</div><!-- /page -->
<script>

    $('#map_canvas').gmap().bind('init', function() { 
    // This URL won't work on your localhost, so you need to change it
    // see http://en.wikipedia.org/wiki/Same_origin_policy
    $.getJSON( 'http://jquery-ui-map.googlecode.com/svn/trunk/demos/json/demo.json', function(data) { 
        $.each( data.markers, function(i, marker) {
            $('#map_canvas').gmap('addMarker', { 
                'position': new google.maps.LatLng(marker.latitude, marker.longitude), 
                'bounds': true 
            }).click(function() {
                $('#map_canvas').gmap('openInfoWindow', { 'content': marker.content }, this);
            });
        });
    });
});
</script>
</body>
</html>

输出:

enter image description here

提前致谢。

最佳答案

我的移动网站的解决方案是设置样式 position:absolute;宽度:100%; height:100%; 对于 Canvas div。您可以使用 topbottom 样式为工具栏留出空间。

关于jquery - 如何使用 jQuery Mobile 显示全屏谷歌地图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10406252/

相关文章:

JavaScript 表单提交链接

javascript - 获取类型错误:e is undefined in firebug while running a script

javascript - 用 Instagram 图片替换 Google map 标记

jquery - 从函数触发jquery移动页面转换

javascript - 如何在 Jquery Mobile 中拖动项目

android - HTML5 - 安卓屏幕尺寸

javascript - 延迟检查其他复选框更改的多个复选框选择

javascript - 如何使用 jQuery 生成动态 ID?

javascript - 单击时显示半径圆 - Google map

javascript - 设置后如何删除谷歌地图API标记