When showing a google map in jquery mobile it appears (after reading the forums) that code like the following is required:
Well here how I did it and it worked for me.
<div data-role="page" id="atm" data-theme="b">
<div data-role="header" data-theme="b" data-position="inline" class="classHeader">
<a href="#home" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Options</a>
<h1>Location</h1>
</div>
<div data-role="content" id="map_canvas"></div>
<div data-role="footer" data-position="fixed" data-theme="b" class="classFooter">
<h1>Copyright © 2011.</h1>
</div>
</div>
Then add these to your CSS File.
.classHeader{
height:10% !important;
}
.classFooter{
height:10% !important;
}
#map_canvas{
padding-top:10%;
padding-bottom:10%;
height:auto;
position:absolute;
width:100%;
height:88%;
max-height:1600px;
overflow:hidden;
display:block;
}
This is working perfectly for me.
Quick and dirty fix that worked for me:
$('[data-role=content]')
.height(
$(window).height() -
(5 + $('[data-role=header]').last().height()
+ $('[data-role=footer]').last().height())
);
// tell google to resize the map
google.maps.event.trigger(map, 'resize');
There is an official example for this here: http://view.jquerymobile.com/master/demos/examples/maps/geolocation.php
HTML:
<div data-role="page" class="page-map">
<script src="map.js"></script>
<link rel="stylesheet" href="map.css" />
<div data-role="header"><h1>Map View</h1></div>
<div data-role="content">
<div id="map-canvas">
<!-- map loads here... -->
</div>
</div>
</div>
CSS:
.page-map, .ui-content, #map-canvas { width: 100%; height: 100%; padding: 0; }
This is not a Google maps related issue, the thing is, you need to SET a specific width and height for your Map canvas, your code could be rewritten like:
<div data-role="page" data-theme="b" class="page-map" style="width:100%; height:100%;">
<div data-role="header"><h1>Map Page</h1></div>
<div data-role="content" style="padding:0;">
<div id="map_canvas" style="width:300px; height:300px;"></div>
<p id="text">Lorem ipsum legere facilisi conclusionemque pro et, sint aperiam vel at. No postea scaevola vivendum duo, et vix erant paulo. Ex fuisset perfecto vix. No sit laudem noster scriptorem, probatus assueverit ius cu.</p>
</div>
</div>
Example link
UPDATE: Have a look @Blowsie comment, you may also check the jquery-ui-map plugin.