我正在尝试将Google Maps API 3与jQuery Mobile一起使用,并且无法让我的外部页面加载地图.我检查了Firebug,看来地图正在创建但隐藏在页面上.我可以让主页成功加载地图,我可以使用链接上的rel ="external"属性获取外部页面以成功加载地图.但对于不使用rel ="external"的外部页面,地图不会显示.
这是我的代码:
的index.html
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<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>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>jQuery Mobile</h1>
</div>
<div data-role="content">
<ul data-role='listview' id='menu'>
<li><a href="pages/map.html">external map page (does not work)</a></li>
<li><a href="pages/map.html" rel="external">map page with rel=external (works)</a></li>
</ul>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
map.html
<!DOCTYPE html>
<html>
<head>
<title>Map</title>
<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>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
<style type="text/css">
html { height: 100% } …Run Code Online (Sandbox Code Playgroud)