diff options
Diffstat (limited to 'resources/map.js')
-rw-r--r-- | resources/map.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/resources/map.js b/resources/map.js new file mode 100644 index 0000000..7e54607 --- /dev/null +++ b/resources/map.js @@ -0,0 +1,25 @@ +$(document).ready(function() { + + var map = L.map( 'map' ); + + L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', { + maxZoom: 18, + attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>' + }).addTo(map); + + function onLocationFound(e) { + var radius = e.accuracy / 2 + + L.marker(e.latlng).addTo(map) + .bindPopup("You are within " + radius + " meters from this point").openPopup(); + } + + function onLocationError(e) { + alert(e.message); + } + + map.on('locationfound', onLocationFound); + map.on('locationerror', onLocationError); + + map.locate({setView: true, maxZoom: 16}); +})( jQuery ); |