user2078935
user2078935

Reputation: 1

Google maps update jquery mobile problems

I want to use the latest version of the JQuery Mobile and I have problems because the Google Maps doesn't works now...

With the version 1.0a2 the google maps works fine but now with the version 1.3.1 I have a blank page !

In my Html code, I use a DIV id="map" like this : div id="map" style="width: 100%; height: 78%;"

The header :

Newest code :

link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
script src="http://code.jquery.com/jquery-1.9.1.min.js">
script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js">

older code :

link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
script src="http://code.jquery.com/jquery-1.4.4.min.js">
script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js">

Does somebody can tell me what is the problem ?

Thank you.

Upvotes: 0

Views: 1029

Answers (2)

SASM
SASM

Reputation: 1312

It works just fine for the latest JQM as well. Try this code as a demo:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Application</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
    <script type="text/javascript" 
        src="https://maps.googleapis.com/maps/api/js?key=**your key**&sensor=true"></script>
    <script type="text/javascript">
        function initialize() {
            var mapOptions = {
                center: new google.maps.LatLng(-34.397, 150.644),
                zoom: 8,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
        }
        google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas, #map-page { height: 100% }
    </style>
    </head>

    <body>

    <div data-role="page" id="map-page" data-url="map-page">

        <div data-role="header">                
            <h1>Header</h1>                
        </div><!-- /header -->

        <div data-role="content" id="map-canvas">
            <p>Page content goes here.</p>
        </div><!-- /content -->

        <div data-role="footer" data-id="myfooter" class="ui-bar" data-position="fixed">
            <h4>Footer</h4>
        </div><!-- /footer -->

    </div><!-- /page -->

</body>

The key here is that you should provide an id to your data-role="page" and set this to height 100% along with your map div. Notice that on my css

#map-canvas, #map-page { height: 100% }

Upvotes: 0

Zahid Khan
Zahid Khan

Reputation: 1260

You can try it by downloading the jquery file and give him static link, use this link https://developers.google.com/maps/documentation/staticmaps/ to generate your google map code to use within div and other information regarding google maps. I can'nt find any problem with this one above. working fine as i used it.

Upvotes: 0

Related Questions