# Ionic Native Geolocation is not working on Android

**URL:** <https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320>\
**Category:** ionic-v3\
**Created:** [March 9, 2017, 1:02pm UTC](https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320 "2017-03-09T13:02:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [March 9, 2017, 1:02pm UTC](https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320/1 "2017-03-09T13:02:12Z")

</div>

I have the following code using [Ionic Native Geolocation](https://ionicframework.com/docs/v2/native/geolocation/):

```
import { Geolocation } from 'ionic-native';

    this.platform.ready().then(() => {
        alert('loadMap about to getCurrentPosition');
          Geolocation.getCurrentPosition(options).then((position) => {
        alert('loadMap getCurrentPosition');
            let latLng: google.maps.LatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            bound.extend(latLng);
            this.load(bound);
          });
    });

```

When I run this as `ionic serve` in a browser, or I build it and run it on `iOS Simulator` (`Xcode`), it works. However, when I build this for `Android`, and try run it, the first alert gets fired, but not the second.

That means for `Android` only, `Geolocation.getCurrentPosition...` is not working.

I do have another page that can render a map via `this.map = new google.maps.Map(htmlElement, mapOptions);`, so it looks like the issue is with getting the current position. When I install the app, I do get this message however:

> ```
> Allow AppName to access the device's location?
> DENY ALLOW
> 
> ```

To which I click `Allow`.

Does anyone know what I am doing incorrectly, or if there are some missing steps in the Android install and build process?

Thanks

---

<div class="post-metadata">

**Author:** ![PurpleEdge](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/purpleedge/32/107517_2.png) [@PurpleEdge](https://forum.ionicframework.com/u/PurpleEdge)\
**Post date:** [March 10, 2017, 3:10am UTC](https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320/2 "2017-03-10T03:10:39Z")

</div>

I had the opposite experience, Geolocation wouldn’t work in the browser, but did work on an Android device. Sorry, not much help!

---

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [March 10, 2017, 5:29am UTC](https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320/3 "2017-03-10T05:29:21Z")

</div>

Maybe try make sure your browser has location settings enabled. Not sure but that may help.

---

<div class="post-metadata">

**Author:** ![PurpleEdge](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/purpleedge/32/107517_2.png) [@PurpleEdge](https://forum.ionicframework.com/u/PurpleEdge)\
**Post date:** [March 10, 2017, 5:47am UTC](https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320/4 "2017-03-10T05:47:54Z")

</div>

Thanks, yes that makes sense!

This is the code I am using, it is slightly different to yours…

```
import { Geolocation, GoogleMapsLatLng } from 'ionic-native';

  getCurrentLocation(): Promise<any> {
        return new Promise(resolve => {
          Geolocation.getCurrentPosition()
            .then((resp) => {
              let currentLocation = new GoogleMapsLatLng(resp.coords.latitude, resp.coords.longitude);
              console.log("4 - Current location:", currentLocation)
              resolve(currentLocation);
            })
        })
      }

```

[EDIT] Do you have “Location” enabled on your device??

---

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [March 10, 2017, 6:03am UTC](https://forum.ionicframework.com/t/ionic-native-geolocation-is-not-working-on-android/82320/5 "2017-03-10T06:03:50Z")

</div>

That code is similar. I know in Chrome setting you can enable sharing location.

Yes, the app prompts the user if they want to share location. For me it’s working on my phone, and I am using an iOS emulator that works, so I have enough to do all my testing. Thanks
