Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229726

Geolocation Plugin doesn't work on Android

$
0
0

No, you're right. I posted too quick. I'm calling from this.platform.ready also. Had to take a second look. And actually, I'm running my this.geolocation.getCurrentPosition() like so:
userCoordinates: object;
constructor (public geolocation: Geolocation) {
this.userCoordinates = {};
this.userCoordinates['latitude'];
this.userCoordinates['longitude'];
this.initializeApp();
}

initializeApp() {
this.platform.ready().then(() => {
this.geolocation.getCurrentPosition().then((position => {
this.userCoordinates['latitude'] = position.coords.latitude;
this.userCoordinates['longitude'] = position.coords.longitude;
})
.catch((error) => {
console.warn(error);
})
}
}

Sorry for no indentation in my example. No idea why it wont indent. It looks like i'm doing a couple/few things I shouldn't be doing (like running the function from my constructor?), but it works. maybe initializing the userCoordinates object ahead of time is helping on my end?


Viewing all articles
Browse latest Browse all 229726

Trending Articles



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