Guest User

Untitled

a guest
May 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. function getLocation() {
  4. navigator.geolocation.getCurrentPosition(showLocation, showError, {enableHighAccuracy:true, maximumAge:600000});
  5. }
  6.  
  7. function showError(error) {
  8. alert(error.code + ' ' + error.message);
  9. }
  10.  
  11. function showLocation(position) {
  12. var latlong = position.coords.latitude + '/' + position.coords.longitude;
  13. $('h2 span').html(position.coords.latitude + ', ' + position.coords.longitude);
  14. jQuery.post('/geo/ajax_nearby/' + latlong, null, function(data, status){
  15. $.each(data.spots, function(i,spot){
  16. $("<li></li>").html(spot.name + "(" + spot.latlong + ")").appendTo("ul");
  17. });
  18. }, 'json');
  19. }
  20.  
  21. if(navigator.geolocation){
  22. getLocation();
  23. }
  24.  
  25. });
Add Comment
Please, Sign In to add comment