Skip to content

Commit

Permalink
fix: map translation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ofirc77 committed Dec 18, 2024
1 parent e25dddf commit 176442d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/pages/components/map-related/MapContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { t } from 'i18next'
import { useRef } from 'react'
import { useRef, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Marker, Polyline, Popup, TileLayer, useMap } from 'react-leaflet'
import { Icon, IconOptions, Marker as LeafletMarker } from 'leaflet'
import { busIcon, busIconPath } from '../utils/BusIcon'
Expand Down Expand Up @@ -29,7 +30,6 @@ export function MapContent({ positions, plannedRouteStops, showNavigationButtons
const plannedRouteLineColor = 'black'
const actualRouteStopMarker = getIcon(actualRouteStopMarkerPath, 20, 20)
const plannedRouteStopMarker = getIcon(plannedRouteStopMarkerPath, 20, 25)

const navigateMarkers = (positionId: number) => {
const loc = positions[positionId]?.loc
if (!map || !loc) return
Expand All @@ -39,12 +39,27 @@ export function MapContent({ positions, plannedRouteStops, showNavigationButtons
marker.openPopup()
}
}
const { i18n } = useTranslation();

Check failure on line 42 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
const [tileUrl, setTileUrl] = useState('https://tile-a.openstreetmap.fr/hot/{z}/{x}/{y}.png');

Check failure on line 43 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
useEffect(() => {
const handleLanguageChange = (lng: string) => {
console.log('Language changed to:', lng);

Check failure on line 46 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
const newUrl = lng === 'he'

Check failure on line 47 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Insert `⏎·······`
? 'https://tile-a.openstreetmap.fr/hot/{z}/{x}/{y}.png'

Check failure on line 48 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Insert `··`
: 'https://tile-a.openstreetmap.fr/osmfr/{z}/{x}/{y}.png?lang=en';

Check failure on line 49 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Replace `········:·'https://tile-a.openstreetmap.fr/osmfr/{z}/{x}/{y}.png?lang=en';` with `··········:·'https://tile-a.openstreetmap.fr/osmfr/{z}/{x}/{y}.png?lang=en'`
setTileUrl(newUrl);

Check failure on line 50 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
};

Check failure on line 51 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
i18n.on('languageChanged', handleLanguageChange);

Check failure on line 52 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
return () => {
i18n.off('languageChanged', handleLanguageChange);

Check failure on line 54 in src/pages/components/map-related/MapContent.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
};
}, []);

return (
<>
<TileLayer
attribution='&copy <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://tile-a.openstreetmap.fr/hot/{z}/{x}/{y}.png"
url={tileUrl}
/>
<div className="map-index">
<MapIndex
Expand Down

0 comments on commit 176442d

Please sign in to comment.