Could someone please have a look at my code and tell me what I'm doing wrong? I have spend so much time now trying out different things but haven't been successful. Tanks to everybody who can help me!
- calling this page directly works
- calling this page from the previous page with link type "external" works
- calling this side normally from one jQueryMobile page to this one, doesn't work and shows the map Empty, after clicking Reload, everything is perfect
The code:
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.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/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=places"></script>
</head>
<body>
<div data-role="page" id="basic_map">
<script type="text/javascript">
$("div:jqmData(role='page'):last").bind('pageinit', function() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
initialize(position.coords.latitude,position.coords.longitude);
});
}
});
function initialize(lat,lng) {
var latlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
</script>
<div data-role="header" data-theme="b" data-position="fixed" data-inset="false">
<h1>My</h1>
<a href="index.html" data-icon="home" class="ui-btn-right" data-iconpos="notext" >Home</a>
</div>
<div data-role="content">
<h4>Map</h4>
<div class="ui-bar-c ui-corner-all " >
<div id="map_canvas" style="height:300px;"></div>
</div>
</div>
</div>
</body>
</html>
--> no change, same issue like before 2.) I changed the function to start as you described above in that case even if i reload the page, the map is not shown anymore :-) i am completely confused and have no idea,....;-)
– Reinhard Jun 07 '12 at 12:41