I'm having problems accessing values of my data objects in Vue, after loading the Google maps-api.
Data:
data() {
return {
lat : 0,
long : 0,
location: '46.414382,10.013988'
}
}
My method, that I call.
methods: {
randomLocation: function(){
this.lat = Math.random() * (90 + 90) - 90;
this.long = Math.random() * (180 + 180) - 180;
this.location = this.lat + ',' + this.long;
console.log("Random location: ", this.location);
GoogleMapsLoader.load(
function(google) {
var sv = new google.maps.StreetViewService();
console.log(this.location);
}
);
}
}
The console prints an error when I call randomLocation. It says it can't access this.location int GoogleMapsLoader.load(...). Why is that and how can I fix it?