# Webview (iframe) with geolocation

**URL:** <https://community.glideapps.com/t/webview-iframe-with-geolocation/24347>\
**Category:** Ask for Help\
**Created:** [March 16, 2021, 12:01pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347 "2021-03-16T12:01:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alesanderlopez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alesanderlopez/32/23435_2.png) [@alesanderlopez](https://community.glideapps.com/u/alesanderlopez)\
**Post date:** [March 16, 2021, 12:01pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/1 "2021-03-16T12:01:52Z")

</div>

Hello,

I have a problem to access for the user geolocation inside the iframe and I guessed that the problems is because the iframe have a sandbox and don’t have allow=“geolocation”.

I made a custom component in ReactJS with Mapbox and many code in JS that requires geolocation because I need for my app a location of users.

 ![Captura de pantalla 2021-03-16 a las 11.51.14 a. m.](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/9/c927ca3d0e824934aeb7e2de711a2f17c8dd1759.png)

// Without iframe inside Glide works fine.  
[https://www.app.roundroute.es/mapview?latitude=28.14336395263672&longitude=-15.65500259399414](https://www.app.roundroute.es/mapview?latitude=28.14336395263672&longitude=-15.65500259399414)

To get user geolocation i’m using:  
navigator.geolocation.getCurrentPosition  
navigator.geolocation.watchPosition

getRegion = () =\> this.region;

getCurrentPosition = async () =\> {  
if (navigator.geolocation) {  
navigator.geolocation.getCurrentPosition(position =\> {  
if (position &&  
position.coords &&  
position.coords.latitude &&  
position.coords.longitude) {  
this.setRegion(position.coords);  
}  
}, this.positionError, options);  
}  
else {  
console.log(‘getCurrentPosition.navigation.undefined\_geolocation’, navigator);  
}  
return this.region;  
}

watchPosition = () =\> {  
if (navigator.geolocation) {  
this.trackId = navigator.geolocation.watchPosition(position =\> {  
if (position &&  
position.coords &&  
position.coords.latitude &&  
position.coords.longitude) {  
this.setRegion(position.coords);  
}  
}, this.positionError, options);  
}  
else {  
console.log(‘getCurrentPosition.navigation.undefined\_geolocation’, navigator);  
}  
}

clearWatch = () =\> {  
if (navigator.geolocation && this.trackId !== null) {  
navigator.geolocation.clearWatch(this.trackId);  
}  
}

positionError = (error) =\> {  
switch (error.code) {  
case error.PERMISSION\_DENIED:  
this.setError(“Error: Permisos GPS rechazados.”);  
break;  
case error.POSITION\_UNAVAILABLE:  
this.setError(“Error: Información de la localización no disponible.”);  
break;  
case error.TIMEOUT:  
this.setError(“Error: Tiempo de espera para acceder a la ubicación elevado.”);  
break;  
case error.UNKNOWN\_ERROR:  
this.setError(“Error: Error con el GPS desconocido.”);  
break;  
default:  
this.setError(error.message);  
break;  
}  
}

The methods are rejected always with ERROR.PERMISSION\_DENIED and the browser have enabled the GPS, I checked the permissions from the page with the chrome console:

// Works great  
navigator.geolocation.getCurrentPosition(position =\> console.log(position));

I made a new view with the iframe and location component and I have a retry each 5 seconds and when the location are enabled and the permissions accepted are rejected yet.

Thanks.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [March 16, 2021, 12:41pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/2 "2021-03-16T12:41:47Z")

</div>

just take geolocation from a distance column or current location switch

---

<div class="post-metadata">

**Author:** ![alesanderlopez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alesanderlopez/32/23435_2.png) [@alesanderlopez](https://community.glideapps.com/u/alesanderlopez)\
**Post date:** [March 16, 2021, 12:50pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/3 "2021-03-16T12:50:28Z")

</div>

I made this view with location switch and inside the webview don’t received the permissions of the parent (glide window.navigator)

 ![Captura de pantalla 2021-03-16 a las 12.47.44 p. m.](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/4/f4d210c3afc9e02d95664835d3e2442fe52b9a9a.jpeg)

---

<div class="post-metadata">

**Author:** ![AymenM](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/aymenm/32/21370_2.png) [@AymenM](https://community.glideapps.com/u/AymenM)\
**Post date:** [March 16, 2021, 1:02pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/4 "2021-03-16T13:02:19Z")

</div>

I’m not sure you’ll ever be able to access localisation details, remember the app is acting as a website on a phone and therefore browsers restrictions applies (safari, chrome…), it’s not like a native app that you download on the stores where you can grant specific authorizations.

---

<div class="post-metadata">

**Author:** ![alesanderlopez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alesanderlopez/32/23435_2.png) [@alesanderlopez](https://community.glideapps.com/u/alesanderlopez)\
**Post date:** [March 16, 2021, 1:12pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/5 "2021-03-16T13:12:11Z")

</div>

Hello AymenM, thanks for your response.

I have checked that the browsers restrictions don’t are the problem getting to the map URL ([RoundRoute](https://www.app.roundroute.es/mapview?latitude=28.14336395263672&longitude=-15.65500259399414)) without glide iframe and the geolocation work fine and then I check the same URL in the same browser received the location ERROR.PERMISSION\_DENIED

I guessed that the iframe need allow=“geolocation”.

This is the iframe in glide:

The sandbox field add limits to the child URL and I hope could add allow=“geolocation” on iframe.

---

<div class="post-metadata">

**Author:** ![AymenM](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/aymenm/32/21370_2.png) [@AymenM](https://community.glideapps.com/u/AymenM)\
**Post date:** [March 16, 2021, 1:19pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/6 "2021-03-16T13:19:44Z")

</div>

Oh I see, unfortunately I’ll not be able to help you on that, hope that you’ll find a way soon !

---

<div class="post-metadata">

**Author:** ![Purvang\_Joshi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/purvang_joshi/32/12645_2.png) [@Purvang\_Joshi](https://community.glideapps.com/u/Purvang_Joshi)\
**Post date:** [March 16, 2021, 2:05pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/7 "2021-03-16T14:05:45Z")

</div>

I’m using google maps webview. I’ve used construct url method in glide editor.  
It’s working perfect for my projects.  
Let me know how I can help you with google maps.

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [March 16, 2021, 2:33pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/8 "2021-03-16T14:33:57Z")

</div>

@Purvang_Joshi my understanding was that you could not embed any google services in glide webview. If you can would you mind sharing 🕶

---

<div class="post-metadata">

**Author:** ![alesanderlopez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alesanderlopez/32/23435_2.png) [@alesanderlopez](https://community.glideapps.com/u/alesanderlopez)\
**Post date:** [March 16, 2021, 2:45pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/9 "2021-03-16T14:45:15Z")

</div>

¿And the Google Maps webview show the user location and work ass gps?

---

<div class="post-metadata">

**Author:** ![Purvang\_Joshi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/purvang_joshi/32/12645_2.png) [@Purvang\_Joshi](https://community.glideapps.com/u/Purvang_Joshi)\
**Post date:** [March 16, 2021, 3:25pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/10 "2021-03-16T15:25:07Z")

</div>

I’ve achieved this from Google Maps Embed API (Documentation [Embedding a map &nbsp;|&nbsp; Maps Embed API &nbsp;|&nbsp; Google Developers](https://developers.google.com/maps/documentation/embed/embedding-map))

I haven’t tried the current location of the user as origin @alesanderlopez

How to implement?  
First of all, create a GCP Project and enable maps Embed API then obtain a key.

Then, You need a construct URL column,

 ![Screenshot 2021-03-16 at 8.39.54 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/e/cec135fc0e88bd4738c46c20ca66e7768385a00e.png)

  
Then, create a template column,

![Screenshot 2021-03-16 at 8.40.31 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/3/43b2f40932c65d1aa26b422235ed3182849409f9.png)  
  
  
  
And, Now create a webview with template column.

 ![Screenshot 2021-03-16 at 8.42.40 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/e/5e9adb0075f413b393d8d4c73c0c3604ca02a8dd.jpeg)

You can change zoom size, map mode, and many more parameters mentioned in the documentation.

Hope that I’ve explained well, @Krivo

---

<div class="post-metadata">

**Author:** ![SantiagoPerez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/santiagoperez/32/16807_2.png) [@SantiagoPerez](https://community.glideapps.com/u/SantiagoPerez)\
**Post date:** [March 16, 2021, 5:27pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/11 "2021-03-16T17:27:13Z")

</div>

@Robert_Petitto I think I read a thread where you mentioned having lost a client due to the basic map features.

Would something like what @Purvang_Joshi did here work for you/your client?

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [March 16, 2021, 5:31pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/12 "2021-03-16T17:31:43Z")

</div>

Thanks for thinking of me. It wasn’t a map the customer needed but rather an address lookup from a keyword (like Eiffel Tower) or an autocomplete verified address from a portion

1600 Pennsylvania Ave → 1600 Pennsylvania Avenue NW, Washington, DC 20500

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [March 16, 2021, 5:35pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/13 "2021-03-16T17:35:56Z")

</div>

@Purvang_Joshi Thanks for sharing. Setting up a GCP project is at the moment a bit of a challenge for me. Lots of things to do before it can be used. Might look at it at a later stage.

Does all the users need to use a google account to use the map - or is that not the case. What about the users accept to privacy policy that Google seems to want you to upload. Is there a pop-up box where the user must accept that privacy policy.

---

<div class="post-metadata">

**Author:** ![alesanderlopez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alesanderlopez/32/23435_2.png) [@alesanderlopez](https://community.glideapps.com/u/alesanderlopez)\
**Post date:** [March 16, 2021, 5:40pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/14 "2021-03-16T17:40:01Z")

</div>

> [@Purvang\_Joshi](#):
>
> I haven’t tried the current location of the user as origin @alesanderlopez

I didn’t show the template component before i going to try use iframe inside the template.

Thanks !

---

<div class="post-metadata">

**Author:** ![alesanderlopez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alesanderlopez/32/23435_2.png) [@alesanderlopez](https://community.glideapps.com/u/alesanderlopez)\
**Post date:** [March 16, 2021, 6:52pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/15 "2021-03-16T18:52:39Z")

</div>

I tried with that method and i’m with the same problem.

The iframe add sandbox and don’t add allow=“geolocation” i supposed that method replace the iframe with sandbox and replace with my iframe.

😕

---

<div class="post-metadata">

**Author:** ![Purvang\_Joshi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/purvang_joshi/32/12645_2.png) [@Purvang\_Joshi](https://community.glideapps.com/u/Purvang_Joshi)\
**Post date:** [March 16, 2021, 7:25pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/16 "2021-03-16T19:25:16Z")

</div>

Setting up a GCP account and obtaining a key is less then 5 Mins. It’s so simple and free too.  
Embed Maps APIs are always free to use.

Your App users doesn’t require any google account. Google Maps will be always shown whether it’s logged in or not. I don’t think privacy policy need here.

Let me know if you need any help regarding GCP Setup.

---

<div class="post-metadata">

**Author:** ![Purvang\_Joshi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/purvang_joshi/32/12645_2.png) [@Purvang\_Joshi](https://community.glideapps.com/u/Purvang_Joshi)\
**Post date:** [March 16, 2021, 7:36pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/17 "2021-03-16T19:36:55Z")

</div>

Hey, You should try with location component.  
Use returned value as origin of map. It should work.  
Also, using “Current+Location” line in origin is acceptable, but it’ll show based on ISP based location.

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [March 16, 2021, 7:47pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/18 "2021-03-16T19:47:18Z")

</div>

@Purvang_Joshi I might a bit of help. Got stock - have to supply privacy policy etc. Any videos on how to do?

---

<div class="post-metadata">

**Author:** ![Purvang\_Joshi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/purvang_joshi/32/12645_2.png) [@Purvang\_Joshi](https://community.glideapps.com/u/Purvang_Joshi)\
**Post date:** [March 16, 2021, 8:06pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/19 "2021-03-16T20:06:53Z")

</div>

Go to [https://console.cloud.google.com/](https://console.cloud.google.com/)

Create a new project or select existing one.

Search ’ Maps Embed API’ and open that.

Now, Click Enable.

Then Search ‘Credentials’ and open that.

Create Credentials → API Key

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [March 16, 2021, 8:22pm UTC](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347/20 "2021-03-16T20:22:21Z")

</div>

@Purvang_Joshi  
Well, I hit the wall where I need to input info about Oauth etc. That is why I have kept asking for more info. Thanks for your patience.

 ![embed maps api](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/1/d1e63b103f290360e4093c099f9d3c70d050eac6.jpeg)

[Next page](https://community.glideapps.com/t/webview-iframe-with-geolocation/24347.md?page=2)
