I have a class to handle geoinformation and google maps services:
class MapService {
    constructor(apiKey) {
        this.apiKey = apiKey;
        this.googleMapsClient = require('@google/maps').createClient({
            key: this.apiKey
        });
    }
    getLocationFromGeoData(){
        this.coords = this.getCoordinatesFromGeoData();
        console.log(this.coords); // => undefined
        return this.coords;
    }
    getCoordinatesFromGeoData(){
        if(navigator.geolocation){
            navigator.geolocation.getCurrentPosition(function(position){
                let coords = {
                    lat: position.coords.latitude,
                    lng: position.coords.longitude
                };
                console.log(coords); // shows object with coordinates
                return coords;
            })
        } else {
            console.warn("Geolocation wird nicht unterstützt!");
        }
    }
}
export {MapService}
My Import:
import {MapService} from './modules/MapServices';
let googleMapsApiKey = document.head.querySelector('meta[name="google-maps-api-key"]');
window.MapService = new MapService(googleMapsApiKey.content);
Now in my Script (Vue.js) I call this class-method getLocationFromGeoData:
var coords = MapService.getLocationFromGeoData();
console.log(coords); // => undefined
Except in getCoordinatesFromGeoData I get undefinedwhen I try to access my coordinates object.
Do I have to take care of something special when returning values from imported classes?
