[Vuejs]-Using Geocorder result in other function in VUe

0๐Ÿ‘

  1. Define a data element for your coordinates in your component, see here for an example: data() {return { markerCoordinates: undefined } }
  2. In your getLocation function, you need a closure that points to the enclosing Vue instance , like this let vm = this. See here, e.g.
  3. In the callback, use this variable to access the data element: vm.markerCoordinates = [{"latitude" :latitude , "longitude" : longitude}]
  4. Access the it in the template simply by using markerCoordinates and in other methods of your component with this.markerCoordinates

Leave a comment