jQM - Gmap Demo

by Dragan Gaić

HTML

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="http://jquery-ui-map.googlecode.com/svn/trunk/ui/jquery.ui.map.js"></script>
<script src="http://jquery-ui-map.googlecode.com/svn/trunk/ui/jquery.ui.map.services.js"></script>
<script src="http://jquery-ui-map.googlecode.com/svn/trunk/ui/jquery.ui.map.extensions.js"></script>
<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
        <title>jQM Complex Demo</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
        <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>-->
        <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> 
    </head>
    <body>
        
        <div data-role="page" id="index">
            <div data-theme="a" data-role="header">
                <h3>
                    Home Page
                </h3>
            </div>
            <div data-role="content">	
                <a data-role="button" href="#map_page">Display map</a>
            </div>
            <div data-theme="a" data-role="footer" data-position="fixed">
                <h3>
                    Home Page
                </h3>
            </div>
        </div>
        
        <div data-role="page" id="map_page">
            <div data-theme="a" data-role="header">
                <h3>
                    Map Page
                </h3>
            </div>
            <div data-role="content" id="content">
                <div id="map_canvas" style="height:100%"></div>
            </div>
            <div data-theme="a" data-role="footer"...

CSS

#content {
    padding: 0;
    position : absolute !important;
    top : 40px !important;
    right : 0;
    bottom : 40px !important;
    left : 0 !important;
}

JavaScript

$(document).on('pageinit', '#index', function(){     
    // This is the minimum zoom level that we'll allow
    var minZoomLevel = 12;

    mapObject.map = new google.maps.Map(document.getElementById('map_canvas'), {
        zoom: minZoomLevel,
        center: new google.maps.LatLng(38.50, -90.50),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
});

$(document).on('pageshow', '#map_page', function (e, data) {
    google.maps.event.trigger(mapObject.map, 'resize');
});

mapObject = {
    map : null
}