Hello all,
I am trying to implement a simple POC using Geolocation. I have created a ionic 4 app and created a method to get the current position of the device using ionic “geolocation.getCurrentPosition()”.
geolocation.getCurrentPosition() is not getting current location from android emulator,
But when i deploy the same code in device, It works perfectly.
I need to get the geolocation from emulator to debug the code easily.
–Calling the below method on button click.
async getLocation() {
await this.platform.ready();
alert(‘Ready’);
const { coords } = await this.geolocation.getCurrentPosition({ timeout: 30000 });
this.location = coords;
alert('Location - ’ + this.location);
}
alert with location co-ordinate is getting displayed only in real device.
Android emulator doesn’t return any error but still no result.
I did enabled the location with high accuracy in the emulator and the location access is working fine in maps app, i tried changing the position using gpx file from the emulator extended control settings. It works fine!
From default google maps app, location was getting correctly, but only with my ionic app, current position is not getting the lat / lng passed from the emulator.
My Current Configuration as below
ionic (Ionic CLI) : 4.1.2
npm : 6.9.0
cordova : 9.0.0 (cordova-lib@9.0.1)
NOdeJs : v10.16.3
Could anyone please help me out to identify the problem?
Thanks in advance