Created
March 11, 2012 07:38
-
-
Save dmozzy/2015451 to your computer and use it in GitHub Desktop.
GeoTaskList Tutorial #1 Locations.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Read the blog post on this gist here http://www.digitalbricklayers.com/2012/03/geotasklist-in-jquery-mobile-and.html --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>GeoTaskList</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width,initial-scale=1" /> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" /> | |
<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry" type="text/javascript"></script> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> | |
<script type="text/javascript" charset="utf-8" src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> | |
<script type="text/javascript" charset="utf-8" src="/ui/jquery.ui.map.full.min.js "></script> | |
</head> | |
<body> | |
<div data-role="page" id="locationPage"> | |
<div data-role="header"> | |
<h1>Locations</h1> | |
</div> | |
<div data-role="content"> | |
<div id="map_canvas" style="width:100%;height:400px"></div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
$( '#locationPage' ).live( 'pageinit',function(event){ | |
function getLocations(mapRef) { | |
$.getJSON( '/locations', | |
function(data) { | |
$.each( data.locations, function(i, location) { | |
var marker = mapRef.addMarker( | |
{ 'position': new google.maps.LatLng(location.lat, location.lng), 'bounds':true, 'zIndex':5, 'draggable':true}); | |
marker.click(function() { | |
mapRef.openInfoWindow({ 'content': location.name }, marker); | |
}); | |
}); | |
}); | |
} | |
$(function() { | |
$('#map_canvas') | |
.gmap({ | |
'mapTypeId':google.maps.MapTypeId.ROADMAP, 'zoom': 10, 'disableDefaultUI':true, | |
'zoomControl':true, 'scaleControl':true, | |
'callback': | |
function() { | |
getLocations(this); | |
} | |
}); | |
}) | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment