SHARE
TWEET

Untitled

a guest Sep 20th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mounted() {
  2.   // call methods when component is done "mounting" :wink:
  3.   this.getUserLocation();
  4.   this.trackUserLocation();
  5. },
  6. methods: {
  7.   getUserLocation() {
  8.     // get user position
  9.     window.navigator.geolocation.getCurrentPosition((position) => {
  10.       const { latitude, longitude } = position.coords;
  11.       console.log(`Your user is positioned at Lat: ${latitude}, Lng: ${longitude}`)
  12.     });
  13.   }
  14.  
  15.   trackUserLocation() {
  16.     // track/follow user position
  17.     window.navigator.geolocation.watchPosition(pos => {
  18.       const { latitude, longitude } = pos.coords;
  19.       console.log(`Your user is positioned at Lat: ${latitude}, Lng: ${longitude}`);
  20.     });
  21.   }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top