Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mounted() {
- // call methods when component is done "mounting" :wink:
- this.getUserLocation();
- this.trackUserLocation();
- },
- methods: {
- getUserLocation() {
- // get user position
- window.navigator.geolocation.getCurrentPosition((position) => {
- const { latitude, longitude } = position.coords;
- console.log(`Your user is positioned at Lat: ${latitude}, Lng: ${longitude}`)
- });
- }
- trackUserLocation() {
- // track/follow user position
- window.navigator.geolocation.watchPosition(pos => {
- const { latitude, longitude } = pos.coords;
- console.log(`Your user is positioned at Lat: ${latitude}, Lng: ${longitude}`);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement