Skip to content

Commit

Permalink
Add admin layer in basemap
Browse files Browse the repository at this point in the history
  • Loading branch information
barshathakuri committed Jun 27, 2024
1 parent a8ec800 commit e726917
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions app/src/components/domain/BaseMap/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { useMemo } from 'react';
import {
useContext,
useMemo,
} from 'react';
import { LanguageContext } from '@ifrc-go/ui/contexts';
import {
isDefined,
isFalsyString,
Expand All @@ -12,7 +16,6 @@ import { type SymbolLayer } from 'mapbox-gl';

import useCountry from '#hooks/domain/useCountry';
import {
adminLabelLayerOptions,
defaultMapOptions,
defaultMapStyle,
defaultNavControlOptions,
Expand Down Expand Up @@ -98,6 +101,34 @@ function BaseMap(props: Props) {
[countries],
);

const {
currentLanguage,
} = useContext(LanguageContext);

const adminLabelLayerOptions : Omit<SymbolLayer, 'id'> = useMemo(
() => {
// ar, es, fr
let label: string;
if (currentLanguage === 'es') {
label = 'name_es';
} else if (currentLanguage === 'ar') {
label = 'name_ar';
} else if (currentLanguage === 'fr') {
label = 'name_fr';
} else {
label = 'name';
}

return {
type: 'symbol',
layout: {
'text-field': ['get', label],
},
};
},
[currentLanguage],
);

return (
<Map
mapStyle={mapStyle ?? defaultMapStyle}
Expand Down

0 comments on commit e726917

Please sign in to comment.