# Geolocation In Webviewer Not Working

**URL:** <https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640>\
**Category:** Questions about Thunkable X\
**Tags:** webviewer\
**Created:** [June 4, 2020, 11:31am UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640 "2020-06-04T11:31:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 11:31am UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/1 "2020-06-04T11:31:31Z")

</div>

I do have the Location Sensor enabled (see screenshot), and still my app cannot detect location. The location permission dialogue doesn’t even pop up. It works great on web, and even mobile browsers on the same phone on which my Thunkable app is installed.

My app is 100% a webviewer app, built with PHP, so I didn’t use any Thunkable blocks in building it.

Please help!

 ![Screen Shot 2020-06-04 at 11.25.37 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/f/8ff857dea2a5b49874b2b0761484e0b039c9f37d.png)

@domhnallohanlon

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 12:26pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/2 "2020-06-04T12:26:26Z")

</div>

Here’s a bit of the javascript I’m using:

```auto
var currentlat;
    var currentlng;
    navigator.geolocation.getCurrentPosition(callback, getError);

    function callback (position) {
        currentlat = position.coords.latitude;
        currentlng = position.coords.longitude;

        console.log("latitude: " + currentlat+"\nlongitude: "+ currentlng);
    }

    function getError(err){
        console.log(err);
        alert(err.message);
    }

```

And here’s what I get when I load that page from my webviewer app:

 ![thunkable-webviewer-geolocation-error](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/1/a1c37e856a87f14a6ae330c7072877313b0747f5.jpeg)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 12:54pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/3 "2020-06-04T12:54:37Z")

</div>

I tried to execute your code, but it didn’t work in the browser.

Check this

[https://x.thunkable.com/projects/5e917bd8c6755a7316cc3a5e/project/properties/designer/](https://x.thunkable.com/projects/5e917bd8c6755a7316cc3a5e/project/properties/designer/)

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 1:21pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/4 "2020-06-04T13:21:50Z")

</div>

@actech

Please do it like this:

```auto
<script>
    // Create the script tag, set the appropriate attributes
    var currentlat;
    var currentlng;

    function getLocation() {
        navigator.geolocation.getCurrentPosition(callback, getError);

        function callback (position) {
            currentlat = position.coords.latitude;
            currentlng = position.coords.longitude;

            console.log("latitude: " + currentlat+"\nlongitude: "+ currentlng);
        }

        function getError(err){
            console.log(err);
            alert(err.message);
        }
    }

    getLocation();
</script>

```

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 1:23pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/5 "2020-06-04T13:23:23Z")

</div>

This show “DataCloneError: The object could not be cloned.”. Check my example.

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 1:27pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/6 "2020-06-04T13:27:54Z")

</div>

Thanks. I’ll check it out and get back to you.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 1:30pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/7 "2020-06-04T13:30:57Z")

</div>

I think your example might work, but to do this, you need to allow geolocation detection in your phone settings

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 1:35pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/8 "2020-06-04T13:35:53Z")

</div>

Geolocation is allowed on this android phone I’m testing with, which is why when I load the app (it’s a web application built with Laravel) in my mobile browser, geolocation works fine.

But upon your suggestion, I’m going to install the app on a different android phone. I’ll let you know in a few minutes how it goes. Please stand by.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 1:37pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/9 "2020-06-04T13:37:56Z")

</div>

First, I recommend that you check my example and then use a different phone

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 1:44pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/10 "2020-06-04T13:44:28Z")

</div>

@actech I really appreciate the quick response. Thank you!

I looked at your example and simply copy-pasted your js snippet into the relevant page on my page that needs the geolocation, button and all.

Currently installing the app in a different android phone. When it’s done, I’m going to click your button and let you know what I find.

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 2:18pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/11 "2020-06-04T14:18:52Z")

</div>

@actech

Still investigating your suggestions.

In the meantime, I went to upload my apk into Google’s Console for an internal test track. They scanned my apk and if you look at this warning, you can clearly tell that LOCATION is not listed in the required permissions.

I’m positive that this means my downloaded Thunkable apk does not include location in the permissions list, even though I included Thunkable’s Location Sensor in my app. See screenshot.

 ![Screen Shot 2020-06-04 at 2.12.17 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/f/ff23f3f102ee877d09e10361ba4a889c7973144d.jpeg)

Just thought I’d point that out and get your opinion on it. What

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 2:22pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/12 "2020-06-04T14:22:17Z")

</div>

I don’t use Thunkable X to download projects from Google Play and for this reason I can’t say anything.

I gave you an example that works for me in browser view and in Live on Android 9 and 8.

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 2:28pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/13 "2020-06-04T14:28:00Z")

</div>

No, that is not what I did. I UPLOADED my Thunkable apk into Google, so that my testing group could download that private release for internal testing purposes. Part of that process is Google scanning the APK to see what permissions it requires.

I was just pointing out that LOCATION should have been listed in that little report from Google, but it wasn’t. Could that be one of the reasons why I’m struggling with location?

PS: I tried your example in the app and got exactly the same results as before. Uploading to Google is just something else that I was trying out when I noticed that location was not listed, meaning the Thunkable APK is NOT including location services at all.

@actech

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 2:33pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/14 "2020-06-04T14:33:02Z")

</div>

Let me clarify:

When I tested your code, I only took the javascript portion of your example (not the blocks), and pasted into my web app where geolocation is required. Just as before, it works great (gets the location) when viewed in a browser (even mobile browser on my phone), BUT NOT IN MY THUNKABLE WEBVIEWER APP.

This is the challenge.

@actech

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 2:36pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/15 "2020-06-04T14:36:32Z")

</div>

I have updated my example and ask you to run my example in your Live on your Android device and tell me if it works or not. The geolocation data will disappear in about 2 seconds and you need to wait after clicking the button.

 ![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8d6fad4eaff7e747000f0b10f1379a23997e3987.png)

After clicking this button, what happens?

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 2:39pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/16 "2020-06-04T14:39:40Z")

</div>

> [@actech](#):
>
> I have updated my example and ask you to run my example in your Live on your Android device and tell me if it works or not. The geolocation data will Ddisappear in about 2 seconds and you need to wait after clicking the button.

Sounds good. Installing Thunkable Live now. I’ll let you know how it goes. Please stand by.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 2:46pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/17 "2020-06-04T14:46:04Z")

</div>

I installed the apk on my phone and now I see your problem. Yes, it works in Live, but it doesn’t work in apk.

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 2:48pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/18 "2020-06-04T14:48:23Z")

</div>

Thank you! What’s missing? Why is location services not working?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [June 4, 2020, 2:49pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/19 "2020-06-04T14:49:03Z")

</div>

Unfortunately, I can’t give an answer to this question.

---

<div class="post-metadata">

**Author:** ![laudtetteh](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@laudtetteh](https://community.thunkable.com/u/laudtetteh)\
**Post date:** [June 4, 2020, 2:50pm UTC](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640/20 "2020-06-04T14:50:52Z")

</div>

I understand, but Thunkable apps should be able to detect location, correct?

What should I do now?

[Next page](https://community.thunkable.com/t/geolocation-in-webviewer-not-working/592640.md?page=2)
