📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
enable region map
Blue Mouse3cf1ff8621fb
diff --git a/web/app/pages/Project/View/components/InteractiveMap.tsx b/web/app/pages/Project/View/components/InteractiveMap.tsxindex 121d99ffc..a01581651 100644--- a/web/app/pages/Project/View/components/InteractiveMap.tsx+++ b/web/app/pages/Project/View/components/InteractiveMap.tsx@@ -5,14 +5,12 @@ import 'leaflet/dist/leaflet.css'import _round from 'lodash/round'import React, { memo, useState, useMemo, useEffect, useCallback, useRef } from 'react'import { useTranslation } from 'react-i18next'-// eslint-disable-next-lineimport { GeoJSON, MapContainer, useMapEvent } from 'react-leaflet'import { ClientOnly } from 'remix-utils/client-only'import { PROJECT_TABS } from '~/lib/constants'import { Entry } from '~/lib/models/Entry'import { getTimeFromSeconds, getStringFromTime, nFormatter } from '~/utils/generic'-// eslint-disable-next-lineimport { loadCountriesGeoData, loadRegionsGeoData } from '~/utils/geoData'import { useViewProjectContext } from '../ViewProject'@@ -44,7 +42,6 @@ const InteractiveMapCore = ({ data, regionData, onClickCountry, total }: Interacconst [countriesGeoData, setCountriesGeoData] = useState<GeoJsonObject | null>(null)const [regionsGeoData, setRegionsGeoData] = useState<GeoJsonObject | null>(null)const [filteredRegionsGeoData, setFilteredRegionsGeoData] = useState<GeoJsonObject | null>(null)- // eslint-disable-next-lineconst [mapView, setMapView] = useState<'countries' | 'regions'>('countries')const [tooltipContent, setTooltipContent] = useState<TooltipContent | null>(null)const [tooltipPosition, setTooltipPosition] = useState<TooltipPosition>({ x: 0, y: 0 })@@ -58,10 +55,7 @@ const InteractiveMapCore = ({ data, regionData, onClickCountry, total }: InteracuseEffect(() => {const loadGeoData = async () => {try {- const [countries, regions] = await Promise.all([- loadCountriesGeoData(),- Promise.resolve(null), // loadRegionsGeoData()- ])+ const [countries, regions] = await Promise.all([loadCountriesGeoData(), loadRegionsGeoData()])setCountriesGeoData(countries)setRegionsGeoData(regions)setFilteredRegionsGeoData(regions)@@ -225,14 +219,14 @@ const InteractiveMapCore = ({ data, regionData, onClickCountry, total }: Interac)const MapEventHandler = () => {- // const map = useMapEvent('zoomend', () => {- // const currentZoom = map.getZoom()- // const newMapView = currentZoom >= 4 ? 'regions' : 'countries'- // if (newMapView !== mapView) {- // setMapView(newMapView)- // setTooltipContent(null)- // }- // })+ const map = useMapEvent('zoomend', () => {+ const currentZoom = map.getZoom()+ const newMapView = currentZoom >= 4 ? 'regions' : 'countries'+ if (newMapView !== mapView) {+ setMapView(newMapView)+ setTooltipContent(null)+ }+ })return null}