Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement