Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70915

Can't get Geolocation plugin to work in Android Studio

$
0
0

I have a simple app based on Ionic-Vue-leaflet-Capacitor. In the app I want to get the current location of the device. Th function I use (the console.log’s are fore debugging only). I want the function to pass latitude and longitude to this.toLatLng:

    async getCurrentLocation() {
    console.log("Bankjes: entered GetCurrentLocation");
    const Position = await Geolocation.getCurrentPosition();
    console.log('Bankjes: Current position:', Position);
    console.log("Bankjes: ended GetCurrentLocation");
    return this.toLatLng(Position.latitude,Position.longitude)

    },

When I debug the app in Android STudio with an emulator I see the following in logcat:
-The first time the function is called, all the console.log’s fire, but no Position is given by the second console.log.
-All the next times the function is called, only the first console.log fires

Any idea what I am doing wrong?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70915

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>