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
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <title>Create Id</title>
- <link rel="stylesheet" href="css/jquery.mobile-1.2.0.min.css" />
-
- <script src="javascript/jquery.min.js">
- </script>
- <script src="javascript/jquery.mobile-1.2.0.min.js">
- </script>
- <script src="javascript/my.js">
- </script>
- <!-- User-generated css -->
- <style>
- </style>
- <!-- User-generated js -->
- <script>
- try {
- $(function() {
- });
- } catch (error) {
- console.error("Your javascript has an error: " + error);
- }
- </script>
- </head>
-
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
- <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
- <script type="text/javascript">
- var geocoder = new google.maps.Geocoder();
- function geocodePosition(pos) {
- geocoder.geocode({
- latLng: pos
- }, function(responses) {
- if (responses && responses.length > 0) {
- updateMarkerAddress(responses[0].formatted_address);
- } else {
- updateMarkerAddress('Cannot determine address at this location.');
- }
- });
- }
- function updateMarkerStatus(str) {
- document.getElementById('markerStatus').innerHTML = str;
- }
- function updateMarkerPosition(latLng) {
- document.getElementById('info').innerHTML = [
- latLng.lat(),
- latLng.lng()
- ].join(', ');
- }
- function updateMarkerAddress(str) {
- document.getElementById('address').innerHTML = str;
- }
- function initialize() {
- var latLng = new google.maps.LatLng(22.5140014, 39.10491239999999);
- var map = new google.maps.Map(document.getElementById('mapCanvas'), {
- zoom: 8,
- center: latLng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- });
- var marker = new google.maps.Marker({
- position: latLng,
- title: 'Point A',
- map: map,
- draggable: true
- });
-
- // Update current position info.
- updateMarkerPosition(latLng);
- geocodePosition(latLng);
-
- // Add dragging event listeners.
- google.maps.event.addListener(marker, 'dragstart', function() {
- updateMarkerAddress('Dragging...');
- });
-
- google.maps.event.addListener(marker, 'drag', function() {
- updateMarkerStatus('Dragging...');
- updateMarkerPosition(marker.getPosition());
- });
-
- google.maps.event.addListener(marker, 'dragend', function() {
- updateMarkerStatus('Drag ended');
- geocodePosition(marker.getPosition());
- });
- }
- // Onload handler to fire off the app.
- google.maps.event.addDomListener(window, 'load', initialize);
- </script>
- <!-- Home -->
- <body>
-
- <div data-role="page" id="page1">
- <font face="Eurostile" color=green>Foreigners Registration </font><br>
- <style>
- #mapCanvas {
- width: 500px;
- height: 400px;
- float: left;
- }
- #infoPanel {
- float: left;
- margin-left: 10px;
- }
- #infoPanel div {
- margin-bottom: 5px;
- }
- </style>
-
- <div id="mapCanvas"></div>
- <div id="infoPanel">
- <b>Marker status:</b>
- <div id="markerStatus"><i>Click and drag the marker.</i></div>
- <b>Current position:</b>
- <div id="info"></div>
- <b>Closest matching address:</b>
- <div id="address"></div>
- </div>
</html>