Witam w jaki sposób mogę przesłać dane z mounted() chodzi mi o this.positionLat i this.positionLong do center w data.
<script>
import Vue from "vue";
import * as Vue2Leaflet from "vue2-leaflet";
Vue.component("l-map", Vue2Leaflet.LMap);
Vue.component("l-tile-layer", Vue2Leaflet.LTileLayer);
export default {
name: "geolocation",
data() {
return {
url: "http://{s}.tile.osm.org/{z}/{x}/{y}.png",
zoom: 3,
center: [52.346458999999996, 20.9339647],
bounds: null
};
},
methods: {
zoomUpdated(zoom) {
this.zoom = zoom;
},
centerUpdated(center) {
this.center = center;
},
boundsUpdated(bounds) {
this.bounds = bounds;
}
},
mounted() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
this.positionLat = position.coords.latitude;
this.positionLong = position.coords.longitude;
console.log((this.positionLat = position.coords.latitude));
console.log((this.positionLong = position.coords.longitude));
});
}
}
};
</script>