How to allow Geolocation support in an embedded HTML code?

Hello there,
I’m adding a fully coded digital map using mapbox GLJS by embedding the HTML code to a wix webpage. It seems all working fine apart from Geolocation button crossed out and not working . I checked the developer console and it says ‘Geolocation support is not available so the GeolocateControl will be disabled.’

Here is the current page:
www.fwdesign. com/dunstablemap2

Here is the HTML code embedded to the webpage:
glitch. com/edit/#!/dunstable-digital-map

Please help!

Hello from the Wix DevRel Team!

This sounds like an issue that has more to do with the embedded mapbox than Wix itself. Checking the console on my local machine shows the following error:

public/pages/lubjy.js: Unexpected token, expected "{" (12:32)

  10 | })
  11 |
> 12 | function getCurrentGeolocation(): Promise<Object>
     |                                 ^
  13 |

If your getCurrentGeolocation function is in fact already defined, you want a semi-colon ( ; ) on line 12, not a colon ( : ).

Additionally, I’m also getting the same warning in the console that says:

Geolocation support is not available so the GeolocateControl will be disabled.

Looking at the documentation, it appears that this is a browser-specific issue. While it doesn’t appear to be working for me in Chrome or Firefox, the GeolocateControl does work when I test it in Safari, which also confirms that it’s a browser-specific issue.

There might be a way to manually override this for every specific browser, but it might also be one of those things that you’re unable to fix until updates are made to each browser, or a consistent, cross-browser web standard is adopted for geolocation.

Hope this helps!

Rob

Hi Rob,
Thanks for getting back to me.

I checked the map on wix via different browsers already, but none of them worked including chrome, safari and firefox. (www.fwdesign. com/dunstablemap2) What works though is the map on glitch works across the browsers. (glitch. com/edit/#!/dunstable-digital-map)

This proves that the references from Mapbox are working yet something disables Geolocation support when the code is embedded on wix.

I removed getCurrentGeolocation function and republished the site. Do you have any idea why Geolocation is disabled in the process?

Thanks!
Jun

@junsoy0808 Is this a permission issue? You can try to search all iframes in the document, then update its attributes (permission) to include geo. Do it in the custom code (under Wix dashboard - not Editor/iframe)

@certified-code Thanks for this! Could you kindly give me an example of the custom code please? I’m a designer not a developer so need your help please! :pray:t3:

@junsoy0808

Try this in the custom code - select - hope it works.

<script>
    // get all iframes in the document and set the permission with geo
    var iframes = document.getElementsByTagName('iframe');
    for (var i = 0; i < iframes.length; i++) {
        iframes[i].setAttribute('allow', 'geolocation');
    }
</script>

@certified-code Thanks for this! I tried as below but still it didn’t work… Have I done something wrong?

Btw, this is the coded map I need to implement:
dunstable-digital-map.glitch. me

I am having the same issue.

hi @junsoy0808

dit you ever got this solved? i have the same issue

I have the same issue with geolocation not being allowed. Will Wix be allowing this functionality anytime soon?