diff --git a/src/CountryPage/SubNationalVisualization/CountryMaps/index.tsx b/src/CountryPage/SubNationalVisualization/CountryMaps/index.tsx index ffaedf8..ad10f65 100644 --- a/src/CountryPage/SubNationalVisualization/CountryMaps/index.tsx +++ b/src/CountryPage/SubNationalVisualization/CountryMaps/index.tsx @@ -1,3 +1,5 @@ +/* eslint-disable no-lonely-if */ +/* eslint-disable no-underscore-dangle */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { useEffect, useRef, useState } from 'react'; import maplibreGl from 'maplibre-gl'; @@ -202,7 +204,23 @@ export function CountryMap(props: Props) { ], ]); (map as any).current.scrollZoom.disable(); - (map as any).current.addControl(new maplibreGl.NavigationControl()); + (map as any).current.on('wheel', (event: any) => { + if (event.originalEvent.ctrlKey) { + // Check if CTRL key is pressed + event.originalEvent.preventDefault(); // Prevent chrome/firefox default behavior + if (!(map as any).current.scrollZoom._enabled) + (map as any).current.scrollZoom.enable(); // Enable zoom only if it's disabled + } else { + if ((map as any).current.scrollZoom._enabled) + (map as any).current.scrollZoom.disable(); // Disable zoom only if it's enabled + } + }); + /* + (map as any).current.addControl( + new maplibreGl.NavigationControl(), + 'top-right', + ); + */ let districtHoveredStateId: string | null = null; (map as any).current.on('mousemove', `layer_${mapLayer.id}`, (e: any) => { (map as any).current.getCanvas().style.cursor = 'pointer'; @@ -261,9 +279,30 @@ export function CountryMap(props: Props) { margin: '0 auto', }} > +
+ Use ctrl (or cmd for mac) + scroll to zoom the map +
+