Ionic geolocation

Hi to all, I’m trying to geolocate user in yours current position with ionic-native/geolocation plugin.
My snippet of code is:

this.geolocation.getCurrentPosition().then(res => {
      this.myLat = res.coords.latitude;
      this.myLon= res.coords.longitude;
      console.log(this.start); = new google.maps.Map(this.mapElement.nativeElement, {
        zoom: 7,
        center: {lat: this.myLat, lng: this.myLon}

    }).catch((error) => {
      console.log('Error getting location', error);

On browser it works but on android devices not. What is the trouble? Thanks in advance

what error does it output??

On browser it works fine, on mobile device there is no error but map doesn’t load. this.geolocation.getCurrentPosition().then( res => {}) isn’t carry out

Using android device or ios??

Android device, I said that in first answer

If you want to create Google map app, I recommend you use @ionic-native/google-maps.
The plugin provides the same API for native Google Maps SDK for Android/iOS and Google Maps JavaScript API v3.

And it also provide original Geolocation API.

I had a similar issue recently - geolocation.getCurrentPosition() wasn’t returning anything.

A device restart got this working for me.

When I use ionic-native/google-maps plugin there is an error on my app:

Error: "Uncaught (in promise): TypeError: plugin is undefined

but I’ve installed plugin with these two commands:

npm install @ionic-native/core @ionic-native/google-maps

ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="..." --variable API_KEY_FOR_IOS="..."

I guess you forget to wait platform.ready().

And also ionic serve does not work, because it does not load cordova.

Use ionic cordova run (browser/ios/android) instead.

Adding -l gives the live reload ability.

Now the error is: Error: "Uncaught (in promise): TypeError: google.maps.LocationService is undefined