summaryrefslogtreecommitdiff
path: root/src/components/widgets/Map.astro
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-22 18:34:58 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-22 18:34:58 +0300
commitd0eb8e6a0f85759a34114596976ef4c1eb4f0258 (patch)
treeaf49798a8a255b13e3c0d5b4e56eb50bc8d5a47a /src/components/widgets/Map.astro
parentbbd889b33fcdb2f1f1abf0018841ed50bf2fb0b1 (diff)
Fix scroll
Diffstat (limited to 'src/components/widgets/Map.astro')
-rw-r--r--src/components/widgets/Map.astro88
1 files changed, 74 insertions, 14 deletions
diff --git a/src/components/widgets/Map.astro b/src/components/widgets/Map.astro
index 76d81a4..ec36669 100644
--- a/src/components/widgets/Map.astro
+++ b/src/components/widgets/Map.astro
@@ -24,8 +24,8 @@ const coordinates = {
lon: lon,
};
-// Create map URL with proper coordinates
-const mapUrl = `https://www.openstreetmap.org/export/embed.html?bbox=${coordinates.lon - 0.01},${coordinates.lat - 0.01},${coordinates.lon + 0.01},${coordinates.lat + 0.01}&layer=mapnik&marker=${coordinates.lat},${coordinates.lon}`;
+// Create map URL with proper coordinates and disabled scroll wheel zoom
+const mapUrl = `https://www.openstreetmap.org/export/embed.html?bbox=${coordinates.lon - 0.01},${coordinates.lat - 0.01},${coordinates.lon + 0.01},${coordinates.lat + 0.01}&layer=mapnik&marker=${coordinates.lat},${coordinates.lon}&scrollWheelZoom=false`;
---
<WidgetWrapper id={id} isDark={isDark} containerClass={`max-w-7xl mx-auto ${classes?.container ?? ''}`} bg={bg}>
@@ -33,18 +33,78 @@ const mapUrl = `https://www.openstreetmap.org/export/embed.html?bbox=${coordinat
<div class="mx-auto max-w-7xl p-4 md:px-8">
<div class="relative overflow-hidden rounded-lg shadow-xl dark:shadow-none dark:border dark:border-slate-600">
- <iframe
- width="100%"
- height={height}
- frameborder="0"
- scrolling="no"
- marginheight="0"
- marginwidth="0"
- src={mapUrl}
- title="Mapa lokalizacji CustomWorks"
- class="w-full"
- >
- </iframe>
+ <div class="relative" id="map-container">
+ <iframe
+ width="100%"
+ height={height}
+ frameborder="0"
+ scrolling="no"
+ marginheight="0"
+ marginwidth="0"
+ src={mapUrl}
+ title="Mapa lokalizacji CustomWorks"
+ class="w-full"
+ id="map-iframe"
+ >
+ </iframe>
+ <script>
+ // Disable scroll wheel zoom on the map iframe
+ document.addEventListener('DOMContentLoaded', function () {
+ const mapContainer = document.getElementById('map-container');
+ const mapIframe = document.getElementById('map-iframe');
+
+ if (mapContainer && mapIframe) {
+ // Prevent scroll wheel events from reaching the iframe
+ mapContainer.addEventListener(
+ 'wheel',
+ function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ },
+ { passive: false }
+ );
+
+ // Also prevent touch events that might cause zoom
+ mapContainer.addEventListener(
+ 'touchstart',
+ function (e) {
+ // Only prevent if it's a pinch gesture (multiple touches)
+ if (e.touches.length > 1) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ },
+ { passive: false }
+ );
+
+ // Prevent pinch zoom
+ mapContainer.addEventListener(
+ 'gesturestart',
+ function (e) {
+ e.preventDefault();
+ },
+ { passive: false }
+ );
+
+ mapContainer.addEventListener(
+ 'gesturechange',
+ function (e) {
+ e.preventDefault();
+ },
+ { passive: false }
+ );
+
+ mapContainer.addEventListener(
+ 'gestureend',
+ function (e) {
+ e.preventDefault();
+ },
+ { passive: false }
+ );
+ }
+ });
+ </script>
+ </div>
<div class="absolute bottom-4 right-4">
<a
href={`https://www.openstreetmap.org/search?query=${encodeURIComponent(location)}`}