Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lat1,lng1, first_check = false;
- var watchID = navigator.geolocation.watchPosition(function(position) {
- if(!first_check){
- //first check is false, save these values
- lat1 = position.coords.latitude;
- lng1 = position.coords.longitude;
- //set first check to true
- first_check = true;
- }else{
- // next run, first check is true, so it gets to here
- // pass our coords to the distanceFrom function
- // along with our new set, each time it runs
- distanceFrom({"lat1" : lat1,
- "lng1" : lng1,
- "lat2" : position.coords.latitude,
- "lng2" : position.coords.longitude
- })
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment