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

Sha*_*lal 7 jquery google-maps google-maps-api-3 jquery-mobile

以下代码显示奇怪的输出.我应该看一个全屏移动地图.但出于某种原因,它只显示在屏幕的一部分上.我正在使用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>
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

提前致谢.

Dmi*_* S. 22

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