[Vuejs]-How do I display my current position using Vue Google Maps

0👍

You really should give more information about the dependencies you’re using, and give a proper sample of code (the one you gave us at first will not compile).


From what I can see of the code, it might seem like a reactivity problem.

If you want Vue to register changes when you’re updating an object, be sure to use Vue.set to do so.

Instead of

this.center = {
  lat: position.coords.latitude,
  lng: position.coords.longitude
}

use:

Vue.set(this, 'center', {
  lat: position.coords.latitude,
  lng: position.coords.longitude
})

Alternatively, you could use this trick:

this.center = Object.assign({}, this.center, {
  lat: position.coords.latitude,
  lng: position.coords.longitude
})

Vue.js Reactivity in Depth

Leave a comment