首页 文章

谷歌 Map 更新了jquery移动问题

提问于
浏览
0

我想使用最新版本的JQuery Mobile,我遇到了问题,因为谷歌 Map 现在不能用了......

使用版本1.0a2谷歌 Map 工作正常但现在使用版本1.3.1我有一个空白页面!

在我的Html代码中,我使用DIV id =“map”,如下所示:div id =“map”style =“width:100%; height:78%;”

The header :

最新代码:

link rel = "stylesheet" href = "http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
script src = "http://code.jquery.com/jquery-1.9.1.min.js">
script src = "http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js">

旧代码:

link rel = "stylesheet" href = "http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
script src = "http://code.jquery.com/jquery-1.4.4.min.js">
script src = "http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js">

有人可以告诉我这是什么问题吗?

谢谢 .

2 回答

  • 0

    您可以通过下载jquery文件并给他静态链接来尝试它,使用此链接https://developers.google.com/maps/documentation/staticmaps/生成您在谷歌 Map 中使用的谷歌 Map 代码和其他有关谷歌 Map 的信息 . 我不能发现上面这个问题 . 工作正常,因为我用它 .

  • 0

    它也适用于最新的 JQM . 试试这个代码作为演示:

    <!DOCTYPE html>
        <html>
        <head>
        <meta charset="utf-8">
        <title>Application</title>
    
        <meta name="viewport" content="width=device-width, initial-scale=1">
    
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
    
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
        <script type="text/javascript" 
            src="https://maps.googleapis.com/maps/api/js?key=**your key**&sensor=true"></script>
        <script type="text/javascript">
            function initialize() {
                var mapOptions = {
                    center: new google.maps.LatLng(-34.397, 150.644),
                    zoom: 8,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
            }
            google.maps.event.addDomListener(window, 'load', initialize);
        </script>
        <style type="text/css">
          html { height: 100% }
          body { height: 100%; margin: 0; padding: 0 }
          #map-canvas, #map-page { height: 100% }
        </style>
        </head>
    
        <body>
    
        <div data-role="page" id="map-page" data-url="map-page">
    
            <div data-role="header">                
                <h1>Header</h1>                
            </div><!-- /header -->
    
            <div data-role="content" id="map-canvas">
                <p>Page content goes here.</p>
            </div><!-- /content -->
    
            <div data-role="footer" data-id="myfooter" class="ui-bar" data-position="fixed">
                <h4>Footer</h4>
            </div><!-- /footer -->
    
        </div><!-- /page -->
    
    </body>
    

    这里的关键是你应该为你的 data-role="page" 提供 id 并将其设置为 height 100% 以及 map div . 请注意我的 css

    #map-canvas, #map-page { height: 100% }
    

相关问题