Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps Displaying Incorrectly in JQuery Mobile
    primarykey
    data
    text
    <p>I'm trying to display a Google Map on a JQuery Mobile page, but am having difficulty getting it to display correctly every time the page is loaded.</p> <p>I have two of the main pages working:</p> <ol> <li>index.php</li> <li>map.php</li> </ol> <p>When loading the site from index.php then switching to map.php in the navbar, the map loads the first time. Switching back to index.php and then back to map.php again, the map's center loads in the top left and the full map is not displayed until the screen is touched (none of this occurs on a computer's browser, however). However, if I load map.php first, the map stays in place with any page changes back and forth.</p> <p>My test site is <a href="http://beersandears.net/mbeta/" rel="nofollow noreferrer">http://beersandears.net/mbeta/</a></p> <p>Any ideas on what I am missing? I've gotten to this point from research on the Internet, but nothing I have tried is helping to resolve this issue, including:</p> <ul> <li><a href="https://stackoverflow.com/questions/8918197/jquery-mobile-google-maps-glitch" title="jQuery Mobile &amp; Google Maps Glitch">jQuery Mobile &amp; Google Maps Glitch</a></li> <li><a href="https://stackoverflow.com/questions/9911459/google-map-api-v3-off-center-if-reloaded-not-the-usual-resize-thing" title="Google Map API v3 off center if reloaded &#40;not the usual &#39;resize&#39; thing&#41;">Google Map API v3 off center if reloaded (not the usual 'resize' thing)</a></li> <li><a href="https://stackoverflow.com/questions/9776761/why-is-the-centering-of-my-map-off-in-my-jquery-mobile-google-maps-api3-applic" title="Why is the centering of my map off in my jQuery Mobile / Google Maps API3 application?">Why is the centering of my map off in my jQuery Mobile / Google Maps API3 application?</a></li> </ul> <p>The third one seems very similar to my issue but the solution of using "pageshow" isn't working.</p> <p>Here is the code for map.php:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="&lt;?php bloginfo( 'charset' ); ?&gt;" /&gt; &lt;title&gt;&lt;?php wp_title('|', true, 'right'); ?&gt;&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script src="http://maps.google.com/maps/api/js?key=AIzaSyBtVQWtkD4MjJ3zbe9DXgPqSlC2XDn5K7c&amp;sensor=true" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"&gt;&lt;/script&gt; &lt;style type="text/css"&gt; img { max-width:100%; height:auto; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper" data-role="page" id="map_page"&gt; &lt;div id="header" data-role="header" data-position="fixed" data-id="head"&gt; &lt;h1&gt;WDW Map&lt;/h1&gt; &lt;/div&gt;&lt;!-- end header --&gt; &lt;div id="map_canvas" data-role="content"&gt; &lt;/div&gt;&lt;!-- end content --&gt; &lt;div id="footer" data-id="navbar" data-role="footer" data-position="fixed"&gt; &lt;div id="navbar" data-role="navbar"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="index.php"&gt;WDW Beer List&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="map.php"&gt;WDW Map&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="blog.php"&gt;Articles&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- end navbar --&gt; &lt;/div&gt;&lt;!-- end footer --&gt; &lt;script type="text/javascript"&gt; $(function(){ initializeMap(28.385208623548024,-81.56713485717773); }); function initializeMap(lat,lng) { var adjustedHeight = ($(window).height()); $('#map_canvas').css({height:adjustedHeight}); //$("#map_canvas").height = $(window).height() - $("#header").height() - $("#footer").height(); setTimeout(function() { 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); //var crosshairLayer = new google.maps.KmlLayer('http://freezoo.alwaysdata.net/justcrosshair2.kml', //{preserveViewport: true}); //crosshairLayer.setMap(map); google.maps.event.trigger(map, 'resize'); map.setZoom( map.getZoom() ); }, 500); } &lt;/script&gt; &lt;/div&gt;&lt;!-- end wrapper --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload