jQM - GmapV3 jQuery Mobile plugin 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>
<title>jQM Complex Demo</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" id="index">
<div data-theme="a" data-role="header">
<h3>
Map example
</h3>
</div>
<div data-role="content" id="content">
<div id="map_canvas" style="height:100%"></div>
</div>
</div>
</body>
</html>
CSS
#content {
padding: 0;
position : absolute !important;
top : 40px !important;
right : 0;
bottom : 0 !important;
left : 0 !important;
}
JavaScript
$(document).on('pageinit', '#index',function(e,data){
var poi = "33.89342,-84.30715",
poimg = "http://www.findthebestcarprice.com/public/images/how-to-buy-a-car.png";
$('#map_canvas').gmap({
'zoom': 6
}).bind('init', function(event, map) {
$('#map_canvas').gmap('addMarker', {
'position': poi,
'bounds': true
}).click(function() {
content = '<img src="' + poimg + '" style="float:left;margin-right:5px"><div>Title<div style="font-weight:normal;font-size:x-small">Text details</div></div>';
$('#map_canvas').gmap('openInfoWindow', {
'content': content
}, this);
});
});
});