Problems
First of all, why are you using jQuery Mobile? I do not see the point in your current example.
jQuery Mobile. jQuery Mobile, DOM. , , :
google.maps.event.addDomListener(window, 'load', initialize);
. , .
-, jQuery Mobile, - . :
$(document).delegate('#content', 'pageinit', function () {
navigator.geolocation.getCurrentPosition(initialize);
});
div id , data-role = "page", :
<div id="content" data-role="page">
</div>
. , . Pageinit HEAD. jQuery Mobile , DOM, BODY. , , javascript BODY ( css). , div.
, jQuery Mobile, , jQuery jQuery Mobile. , jQ 1.8.3 jQM 1.2
:
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<style>
#map-canvas {
width: 300px;
height: 300px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(33.89342, -84.30715);
var mapOptions = {
zoom: 10,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Location'
});
}
$(document).on('pageshow', '#wrapper', function(e, data){
initialize();
});
</script>
<div id="wrapper" data-role="page">
<div class="header">
<h3>Test</h3>
<a href="index.html"><img src="images/logo-small.png" alt="logo"/></a>
</div>
<div id="content">
<div id="map-canvas"></div>
</div>
</div>
</body>
</html>
.