*I'm submitting a bug *
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
geolocation plugin not working with some android devices.
it tested on different Android phones to identify current location on map issues, find below results
Coolpad 3600I | Android 6.0.1 | Not working
Redmi note 4 | Android 7, MIUI 9 | Not working
Moto g 3 | Android 6 | Not working
Redmi note 4 | Android 7, MIUI 9 | Not working
Redmi 4 | Android 7.1.2, MIUI 9.1 | working
Moto G4 Plus | Android 7.0 | working
MI Note 3 | Android 6+, MIUI 8+ | working
Honor holly 2 plus | | working
Samsung J7 | | working
Moto g 3 | | working
Expected behavior:
on page load get current location and display with marker on map.
Related code:
ionViewDidLoad(){
this.GetLatLong();
}
GetLatLong(){
this.platform.ready().then(() => {
//============ check location status (Optional) ============
this.diagnostic.isLocationEnabled().then(success => {
alert("location enable = "+JSON.stringify(success));
}, error => {
alert("location enable error = "+JSON.stringify(error));
})
//============ check GPS status (Optional) ============
this.diagnostic.isGpsLocationAvailable().then(success => {
alert("GPS location Available = "+JSON.stringify(success));
}, error => {
alert("GPS location error = "+JSON.stringify(error));
})
//============ check Location Authorization Status (Optional) ============
this.diagnostic.getLocationAuthorizationStatus().then(success => {
alert("app location Authorization= "+JSON.stringify(success));
}, error => {
alert("app location Authorization error = "+JSON.stringify(error));
})
var myoption = {
timeout:5000,
enableHighAccuracy:true
}
this.geolocation.getCurrentPosition(myoption).then(resp => {
this.lattitude = resp.coords.latitude;
this.longitude = resp.coords.longitude;
this.location = "SUCCESS";
})
let latLng = new google.maps.LatLng(this.lattitude, this.longitude);
let mapOptions = {
center: latLng,
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
this.marker = new google.maps.Marker({
map: this.map,
zoom: 14,
animation: google.maps.Animation.DROP,
position: latLng,
});
})
}
Other information:
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.18.0
ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.4.0 ios 4.4.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 25.2.5
ios-sim : 6.1.2
Node : v6.11.2
npm : 3.10.10
OS : macOS High Sierra
Xcode : Xcode 9.0 Build version 9A235
Environment Variables:
ANDROID_HOME : /Volumes/TimeMachine/Android_SDK
Misc:
backend : pro
having same issue here
same problem... the error catch return {}
I found out that the geolocation plugin stopped working after I installed the google map plugin from the 'multiple maps' branch, I reported the issue but the developer told that he doesnt work with compatibilty with other plugins
same issue
========== I have tested these couple of devices ==========
Coolpad 3600I | Android 6.0.1 | Not working
Redmi note 4 | Android 7, MIUI 9 | Not working
Moto g 3 | Android 6 | Not working
Redmi note 4 | Android 7, MIUI 9 | Not working
Redmi 4 | Android 7.1.2, MIUI 9.1 | working
Moto G4 Plus | Android 7.0 | working
MI Note 3 | Android 6+, MIUI 8+ | working
Honor holly 2 plus | | working
Samsung J7 | | working
Moto g 3 | | working
test on Redmi note 4 | Android 7
turn on gps device only not with assistant by wifi or cellular network it's fix my ionic app with geolocation.
Closed because it is an problem with the plugin source
Hey @danielsogl
i don't understand why you close this. it still does not work. what do you mean problem with the plugin source? which plugin? do they have an issue?
Yosi
This is an problem with the geolocation plugin source. The ionic native plugin only wraps the cordova plugin.
Try Background Geolocation instead of Geolocation it solved my problem
Thanks, i will try it
same problem with me :(
@manish29ify , how did you use the BackgroundLocation plugin? i cant find a get location function on it.
Thanks Yosi
@danielsogl
close the OpenIssue it is not a solution. because ionic officially announced ionic native,
so please do needful.
Most helpful comment
========== I have tested these couple of devices ==========
Coolpad 3600I | Android 6.0.1 | Not working
Redmi note 4 | Android 7, MIUI 9 | Not working
Moto g 3 | Android 6 | Not working
Redmi note 4 | Android 7, MIUI 9 | Not working
Redmi 4 | Android 7.1.2, MIUI 9.1 | working
Moto G4 Plus | Android 7.0 | working
MI Note 3 | Android 6+, MIUI 8+ | working
Honor holly 2 plus | | working
Samsung J7 | | working
Moto g 3 | | working