【问题标题】:google map not full screen after upgrade to jquerymobile 1.2升级到 jquerymobile 1.2 后谷歌地图没有全屏显示
【发布时间】:2012-12-11 15:52:15
【问题描述】:

以下示例属于 Tolis Emmanouilidis 并且适用于 jquerymobile 1.0.1 。当我想升级到1.2.0时,地图不是全屏的,只有一部分显示在框架的左上角

互联网上充斥着 jquerymobile 和谷歌地图的例子。升级到 jqm 1.2.0 后,地图有这个问题,关于这个主题的资料不多。

你能帮我解决这个问题吗?

http://jsfiddle.net/jCemG/4/

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Page Title</title> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false&language=el"> </script>
    </head> 

    <body>
        <!-- /page -->
        <div data-role="page" class="page-map" style="width:100%; height:100%;">
            <!-- /header -->
            <div data-role="header" data-theme="b">
                <h1>Map</h1>
                <a href="page_1_intro.html" id="home" rel="external" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
            </div>
            <!-- /content -->
            <div data-role="content" class="ui-bar-c ui-corner-all ui-shadow" style="padding:1em;">
                <div id="map_canvas" style="height:350px;"></div>
            </div>
        </div>
    </body>
</html>

【问题讨论】:

    标签: google-maps jquery-mobile


    【解决方案1】:

    这应该可以解决您的问题:

    $('#map').live('pagebeforeshow',function(e,data){
        $('#map_canvas').height($(window).height() - (10 + $('[data-role=header]').height() - $('[data-role=footer]').height()));
    });
    

    【讨论】:

    • 谢谢 Gajotres,我在使用 jquery.ui.maps 时解决了。重要的是不要在画布样式中使用 width:100% 。相反,在 pagebeforeshow 事件上调整画布大小(您的解决方案)非常感谢
    • 这是一种享受,谢谢 :) 只是为了他人的利益,不要忘记将 $('#MAP').live 更改为您的页面名称 id
    猜你喜欢
    • 2017-08-21
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    • 2017-12-24
    • 1970-01-01
    相关资源
    最近更新 更多