它也适用于最新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>
这里的关键是您应该为您提供一个id
并将data-role="page"
其height 100%
与您的map div
. 请注意,在我的css
#map-canvas, #map-page { height: 100% }