avoid embedding anything else than /embed

This commit is contained in:
vcoppe
2025-01-30 19:25:58 +01:00
parent c189ebd8ca
commit 01cfd448f0

View File

@@ -22,6 +22,7 @@
mapboxgl.accessToken = accessToken; mapboxgl.accessToken = accessToken;
let webgl2Supported = true; let webgl2Supported = true;
let embeddedApp = false;
let fitBoundsOptions: mapboxgl.FitBoundsOptions = { let fitBoundsOptions: mapboxgl.FitBoundsOptions = {
maxZoom: 15, maxZoom: 15,
linear: true, linear: true,
@@ -40,6 +41,10 @@
webgl2Supported = false; webgl2Supported = false;
return; return;
} }
if (window.top !== window.self && !$page.route.id?.includes('embed')) {
embeddedApp = true;
return;
}
let language = $page.params.language; let language = $page.params.language;
if (language === 'zh') { if (language === 'zh') {
@@ -208,14 +213,23 @@
</script> </script>
<div {...$$restProps}> <div {...$$restProps}>
<div id="map" class="h-full {webgl2Supported ? '' : 'hidden'}"></div> <div id="map" class="h-full {webgl2Supported && !embeddedApp ? '' : 'hidden'}"></div>
<div <div
class="flex flex-col items-center justify-center gap-3 h-full {webgl2Supported ? 'hidden' : ''}" class="flex flex-col items-center justify-center gap-3 h-full {webgl2Supported && !embeddedApp
? 'hidden'
: ''} {embeddedApp ? 'z-30' : ''}"
> >
<p>{$_('webgl2_required')}</p> {#if !webgl2Supported}
<Button href="https://get.webgl.org/webgl2/" target="_blank"> <p>{$_('webgl2_required')}</p>
{$_('enable_webgl2')} <Button href="https://get.webgl.org/webgl2/" target="_blank">
</Button> {$_('enable_webgl2')}
</Button>
{:else if embeddedApp}
<p>The app cannot be embedded in an iframe.</p>
<Button href="https://gpx.studio/help/integration" target="_blank">
Learn how to create a map for your website
</Button>
{/if}
</div> </div>
</div> </div>