jquery-mobile - 在 jQuery Mobile 页面中嵌入 Google map

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

我想做的就是在 jQuery 移动页面的内容标签中嵌入一个护目镜 map ,但我无法让它出现在页面上。我猜这是一个小错误,但我已经为此努力了一段时间,任何帮助将不胜感激。

<head>
    <style type="text/css">
        #map_canvas {
            height: 256px;
            width: 384px;
            margin-top: 0.6em;
        }
    </style>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="fbObj1.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css"
    />
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
    />
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css"
    />
</head>

<body>
    <script type="text/javascript">
        geocoder = new google.maps.Geocoder();
        var map = new google.maps.Map($("div#map_canvas"), {
            center: new google.maps.LatLng(37.371940, -122.116470),
            zoom: 11,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });
        map.index = 2;
    </script>
    <div data-role="page">
        <div data-role="header"></div>
        <div data-role="content">
            <div id="map_canvas"></div>
        </div>
        <div data-role="footer" data-position="inline"></div>
    </div>
</body>

最佳答案

以下代码对我有用

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE"></script>  
<script type="text/javascript">      
    function initialize() {
        var myOptions = {
            center: new google.maps.LatLng(37.371940, -122.116470),           
            zoom: 11,          
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };         
        var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
    }     
 </script> 

 <body onload="initialize()"> 

关于jquery-mobile - 在 jQuery Mobile 页面中嵌入 Google map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10118887/

相关文章:

javascript - 以编程方式一次关闭多个 jQuery Mobile 对话框

jquery-mobile - 在 jquery coffeescript 中绑定(bind)点击事件

android - Phonegap Android(不在安卓高清手机上显示谷歌广告)

css - 在 JQM 等表单上禁用 Twitter Bootstrap 样式

javascript - 切换谷歌地图中的信息框

javascript - 从数据库获取 GPS 纬度、经度值并在 map 上绘制标记?

php - 从 C 调用 PHP

javascript - 如何在谷歌地图上显示两个多边形的相交区域?

html - 如何在我的 html 文件中嵌入 WMV 文件

javascript - 如何将新的 Google map 共享链接转换为 iframe 嵌入 html?