Hi,
I 'm new in ionic world and it’s my first question on this forum
I have un problem with the use of Geolocation.getCurrentPosition() .
I’m testing my app on an android device.
I use a button to center a Google Maps on the user location.
If I start my app with GPS on, all is ok = when I click the button the Geolocation.getCurrentPosition() is working.
If I start my app with GPS off, if I dont click the button and turn the GPS on and after I click the button, it’s also working.
But if I start my app with GPS off and I click the button, getCurrentPosition is not working any more even if I turned on again the GPS.
Same thing appen if I start the app with GPS on, turn off, click button, tun on, click button => no more getCurrentPosition.
I think I have to test if the GPS is on before firing getCurrentPosition but I dont know how to do that.
Thinks for your help.
Here my code :
Button in the template file:
<button fab fab-center fab-bottom style="z-index: 999" (click)="geolocMe()">
<ion-icon name='pin'></ion-icon>
</button>
My method in the map.js file :
geolocMe() {
Geolocation.getCurrentPosition().then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
this.markerPosi = new google.maps.Marker({
map: this.map,
position: latLng
});
this.map.panTo(latLng);
});
}
Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
OS: Windows 7 SP1
Node Version: v4.4.3