Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- function getLocation() {
- navigator.geolocation.getCurrentPosition(showLocation, showError, {enableHighAccuracy:true, maximumAge:600000});
- }
- function showError(error) {
- alert(error.code + ' ' + error.message);
- }
- function showLocation(position) {
- var latlong = position.coords.latitude + '/' + position.coords.longitude;
- $('h2 span').html(position.coords.latitude + ', ' + position.coords.longitude);
- jQuery.post('/geo/ajax_nearby/' + latlong, null, function(data, status){
- $.each(data.spots, function(i,spot){
- $("<li></li>").html(spot.name + "(" + spot.latlong + ")").appendTo("ul");
- });
- }, 'json');
- }
- if(navigator.geolocation){
- getLocation();
- }
- });
Add Comment
Please, Sign In to add comment