I am using an HTML frame to provide Google mapping services and it fails with the following message:
5c805f_a2a3b6bafb6145c7759b09524d4e329a.html:57 Geolocation access has been blocked because of a Feature Policy applied to the current document. See Deprecating Permissions in Cross-Origin Iframes - The Chromium Projects for more details.
That link includes the following:
In order for a cross-origin frame to use these features, the embedding page must specify a Feature Policy which enables the feature for the frame. For example, to enable geolocation in an iframe, the embedder could specify the iframe tag as:
Do I need to add the <iframe … > structure to my HTML?
If I do so what is the src= ?
Or can I set a property on the page I am building and allow geolocation for the entire page and how would I do that?
Regards,
Steve
Hi Steve,
What all are you doing in the HtmlComponent ? If you are embedding Google Maps, you shouldn’t have a problem. You don’t need to do geolocation in the HtmlComponent, rather you can use Wix Code directly to do geolocation and then pass the results to the HtmlComponent with messaging. See the article Working with the HTML Component in Wix Code for details on the messaging system.
Let me know what you are trying to do. Code? APIs? etc…
Yisrael
1 Like
Actually I had this working last week on my Android / Chrome - but after the android update it no longer works. My website does work on Windows 10 Microsoft Edge (which prompts me for persmission to use my location on entry and when I expand the map window). I am using Google Maps, I like you suggestion about using Wix Code to do the geolocation so I’ll look into that. Have you verified your geolocation recently using Chrome?
Steve
I usually use Safari (my colleagues ridicule me about this
), but Chrome offers a more robust development environment so I use Chrome for development (with a little bit of Safari because I’m stubborn). I also use Firefox from time to time. In other words, it works on all three. And, just to be sure, I just tested it now in Chrome (on my Macbook Pro), this very moment, as I’m writing this response. And, it works just fine.
Not sure what your issue is, but from my years of development experience, platforms are merely a moving target that we developers need to keep re-aiming our artiillery.
I’ve been testing Google Maps and Place, and browser geolocation, and everything seems to be copacetic.
Thanks I tried the getCurrentGeolocation() method and it worked as advertised. I assume that WIX provides that feature since I didn’t appear to have to use a Google Key to make it work. ( I am using Google Maps on my HTML page so of course I have to have a key for that.)
Another question I had was whether full screen mode is available for the Google Map. I am currently using the free version and so guess that full screen is not available there since WIX banner needs to be displayed. Will converting to a paid version allow full screen?
Regards,
Steve
Hi Steve,
Wix’s Geolocation API is actually the standard browser Geolocation API which is wrapped to provide ease of use. No connection to Google or Google Maps.
The $w.GoogleMap API however does use Google Maps (hence the clever API name) and Wix handles the API key for this interface.
Since you’re using Google Maps in an HtmlComponent, I would recommend reading the forum post Secure a Google Maps API key in an HtmlComponent to make sure that your API key is properly secured.
Yisrael
I have the same issue/question. The iframe I am adding has allow=“geolocation” but the iframe that Wix throws around it (the sandboxed iframe) does not add the allow=“geolocation” attribute to the
Is there a workaround?
Thanks!
Matt

@yisrael-wix I wrote above in my comment that the widget inside the iframe I am trying to install already has the functionality built to grab the geolocation and use it in the map - it is a pre-built app that I am trying to install - so all I want is to add the allow=“geolocation” to the Wix iframe that is wrapped around my iframe not use Wix API. Is this possible is the question.
Thanks
Matt
@mkoch42 No, you can’t enable geolocation for the HtmlComponent . You can perform geolocation on the page and then send the location to the HtmlComponent in a message.
A more secure way to handle web service requests is by using backend (server-side) code. Using backend code you can secure your passwords, API keys, and other secret information. The article Accessing 3rd Party Services explains how this is done. I recommend checking with the service provider to see if they provide a REST interface.
@yisrael-wix
As I wrote above in my comment that the widget inside the iframe I am trying to install already has the functionality built to grab the geolocation and use it in the map - it is a pre-built app that I am trying to install - so all I want is to add the allow=“geolocation” to the Wix iframe that is wrapped around my iframe not use Wix API. Is this possible is the question.
Thanks
Matt
I have several components which I want to use in Wix pages and in several other locations.
Has anyone built an “if wix then use the wix location method, if not wix then just use the standard geolocation”?
Or is there at least a decent code example of the wix geolocation code to do a “find my location and center the map on me”?
Hi Hugh,
As noted above I am using an HTML to use google maps, but this is how I made it work
Regards,
Steve
export function button1_click(event, $w) {
var coords = “1234” ;
//Add your code for this event here:
wixWindow.getCurrentGeolocation()
.then( (obj) => {
var latitude = obj.coords.latitude; // 32.0971036
var longitude = obj.coords.longitude; // 34.774391099999995
var retObject = {
“lat” : latitude,
“lng” : longitude
};
coords = JSON.stringify(retObject);
console.log( “coordinates” , coords);
$w( “#html2” ).postMessage(coords);
} )
. catch ( (error) => {
var errorMsg = error;
console.log( “error on getCurrentGeolocation” , errorMsg);
});
$w( “#html2” ).expand();
$w( “#html2” ).allowFullScreen();
}
Did you finally manage to resolve this issue Matt ? I have exactly the same question : I only need to add allow=“geolocation” to the Wix iframe. Thanks letting me know…