Guest User

Untitled

a guest
Mar 20th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var lat1,lng1, first_check = false;
  2.  
  3. var watchID = navigator.geolocation.watchPosition(function(position) {
  4.     if(!first_check){
  5.         //first check is false, save these values
  6.         lat1 = position.coords.latitude;
  7.         lng1 = position.coords.longitude;
  8.         //set first check to true
  9.         first_check = true;
  10.     }else{
  11.         // next run, first check is true, so it gets to here
  12.         // pass our coords to the distanceFrom function
  13.         // along with our new set, each time it runs
  14.         distanceFrom({"lat1" : lat1,
  15.                       "lng1" : lng1,
  16.                       "lat2" : position.coords.latitude,
  17.                       "lng2" : position.coords.longitude
  18.                     })
  19.     }
  20. });
Advertisement
Add Comment
Please, Sign In to add comment