google map showing blank page in jquery mobile

google map showing blank page in jquery mobile

This google map works when called directly on the browser but displays a blank page when called from another page unless i refreshed it. any help
  1. <!DOCTYPE html>
  2. <html>
  3.     <head> 
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5.         <meta name="viewport" content="width=device-width, initial-scale=1" />
  6.         <meta name="apple-mobile-web-app-capable" content="yes" />
  7.         <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  8.         <title>Create Id</title>
  9.         <link rel="stylesheet" href="css/jquery.mobile-1.2.0.min.css" />
  10.       
  11.         <script src="javascript/jquery.min.js">
  12.         </script>
  13.         <script src="javascript/jquery.mobile-1.2.0.min.js">
  14.         </script>
  15.         <script src="javascript/my.js">
  16.         </script>
  17.         <!-- User-generated css -->
  18.         <style>
  19.         </style>
  20.         <!-- User-generated js -->
  21.         <script>
  22.             try {

  23.     $(function() {

  24.     });

  25.   } catch (error) {
  26.     console.error("Your javascript has an error: " + error);
  27.   }
  28.         </script>
  29.     </head>
  30.    

  31. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  32. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  33. <script type="text/javascript">
  34. var geocoder = new google.maps.Geocoder();

  35. function geocodePosition(pos) {
  36.   geocoder.geocode({
  37.     latLng: pos
  38.   }, function(responses) {
  39.     if (responses && responses.length > 0) {
  40.       updateMarkerAddress(responses[0].formatted_address);
  41.     } else {
  42.       updateMarkerAddress('Cannot determine address at this location.');
  43.     }
  44.   });
  45. }

  46. function updateMarkerStatus(str) {
  47.   document.getElementById('markerStatus').innerHTML = str;
  48. }

  49. function updateMarkerPosition(latLng) {
  50.   document.getElementById('info').innerHTML = [
  51.     latLng.lat(),
  52.     latLng.lng()
  53.   ].join(', ');
  54. }

  55. function updateMarkerAddress(str) {
  56.   document.getElementById('address').innerHTML = str;
  57. }





  58. function initialize() {
  59.   var latLng = new google.maps.LatLng(22.5140014, 39.10491239999999);
  60.   var map = new google.maps.Map(document.getElementById('mapCanvas'), {
  61.     zoom: 8,
  62.     center: latLng,
  63.     mapTypeId: google.maps.MapTypeId.ROADMAP
  64.   });
  65.   var marker = new google.maps.Marker({
  66.     position: latLng,
  67.     title: 'Point A',
  68.     map: map,
  69.     draggable: true
  70.   });
  71.   
  72.   // Update current position info.
  73.   updateMarkerPosition(latLng);
  74.   geocodePosition(latLng);
  75.   
  76.   // Add dragging event listeners.
  77.   google.maps.event.addListener(marker, 'dragstart', function() {
  78.     updateMarkerAddress('Dragging...');
  79.   });
  80.   
  81.   google.maps.event.addListener(marker, 'drag', function() {
  82.     updateMarkerStatus('Dragging...');
  83.     updateMarkerPosition(marker.getPosition());
  84.   });
  85.   
  86.   google.maps.event.addListener(marker, 'dragend', function() {
  87.     updateMarkerStatus('Drag ended');
  88.     geocodePosition(marker.getPosition());
  89.   });
  90. }

  91. // Onload handler to fire off the app.
  92. google.maps.event.addDomListener(window, 'load', initialize);
  93. </script>



  94.         <!-- Home -->
  95.      <body> 








  96.    
  97.     <div data-role="page" id="page1">
  98. <font face="Eurostile" color=green>Foreigners Registration </font><br>

  99. <style>
  100.   #mapCanvas {
  101.     width: 500px;
  102.     height: 400px;
  103.     float: left;
  104.   }
  105.   #infoPanel {
  106.     float: left;
  107.     margin-left: 10px;
  108.   }
  109.   #infoPanel div {
  110.     margin-bottom: 5px;
  111.   }
  112.   </style>
  113.   
  114.   <div id="mapCanvas"></div>
  115.   <div id="infoPanel">
  116.     <b>Marker status:</b>
  117.     <div id="markerStatus"><i>Click and drag the marker.</i></div>
  118.     <b>Current position:</b>
  119.     <div id="info"></div>
  120.     <b>Closest matching address:</b>
  121.     <div id="address"></div>
  122.   </div>
  123. </html>