File tree Expand file tree Collapse file tree 6 files changed +44
-9
lines changed
deployment/frontend/src/components Expand file tree Collapse file tree 6 files changed +44
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { useMap } from 'react-map-gl'
2
+
3
+ export function HideBoundaries ( ) {
4
+ const { current : map } = useMap ( )
5
+ if ( map ) {
6
+ map . on ( 'load' , ( ) => {
7
+ const layersToHide = [
8
+ 'admin-2-boundaries' ,
9
+ 'admin-2-boundaries-bg' ,
10
+ 'admin-3-4-boundaries' ,
11
+ 'admin-3-4-boundaries-bg' ,
12
+ ]
13
+
14
+ layersToHide . forEach ( ( layerId ) => {
15
+ // Check if the layer actually exists in the current style before trying to hide it
16
+ if ( map && map . getLayer ( layerId ) ) {
17
+ map . getMap ( ) . setLayoutProperty (
18
+ layerId ,
19
+ 'visibility' ,
20
+ 'none'
21
+ )
22
+ }
23
+ } )
24
+ } )
25
+ }
26
+ return null
27
+ }
Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ import { type MapRef } from 'react-map-gl'
6
6
import Boundaries from './Boundaries'
7
7
import { SettingsIcon } from '../../icons/SettingsIcon'
8
8
9
- import dynamic from 'next/dynamic' ;
9
+ import dynamic from 'next/dynamic'
10
10
const Modal = dynamic ( ( ) => import ( '@/components/_shared/Modal' ) , {
11
11
ssr : false ,
12
- } ) ;
12
+ } )
13
13
14
14
export default function Settings ( {
15
15
mapRef,
@@ -18,7 +18,7 @@ export default function Settings({
18
18
} ) {
19
19
const [ open , setOpen ] = useState ( false )
20
20
return (
21
- < IconButton tooltip = ' Map settings' onClick = { ( ) => setOpen ( true ) } >
21
+ < IconButton tooltip = " Map settings" onClick = { ( ) => setOpen ( true ) } >
22
22
< SettingsIcon />
23
23
< Modal open = { open } setOpen = { setOpen } className = "max-w-[36rem]" >
24
24
< h2 className = "font-['Acumin Pro SemiCondensed'] text-3xl font-normal text-black mb-5" >
@@ -31,12 +31,8 @@ export default function Settings({
31
31
< div className = "basis-1/2 pr-2" >
32
32
< LabelSelector />
33
33
</ div >
34
- < div className = "basis-1/2" >
35
- < Boundaries mapRef = { mapRef } />
36
- </ div >
37
34
</ div >
38
35
</ Modal >
39
36
</ IconButton >
40
37
)
41
38
}
42
-
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import notify from '@/utils/notify'
15
15
import Spinner from '@/components/_shared/Spinner'
16
16
import { UseFormReturn } from 'react-hook-form'
17
17
import * as turf from '@turf/turf'
18
+ import { HideBoundaries } from '@/components/_shared/HideBoundaries'
18
19
19
20
export function DatafileLocation ( {
20
21
formObj,
@@ -211,6 +212,7 @@ export function DatafileLocation({
211
212
touchZoomRotate = { false }
212
213
initialViewState = { { zoom : 2 } }
213
214
>
215
+ < HideBoundaries />
214
216
< Source
215
217
type = "geojson"
216
218
data = { watch (
@@ -248,6 +250,7 @@ export function DatafileLocation({
248
250
dragRotate = { false }
249
251
touchZoomRotate = { false }
250
252
>
253
+ < HideBoundaries />
251
254
< GeocoderControl
252
255
mapboxAccessToken = "pk.eyJ1IjoicmVzb3VyY2V3YXRjaCIsImEiOiJjbHNueG5idGIwOXMzMmp0ZzE1NWVjZDV1In0.050LmRm-9m60lrzhpsKqNA"
253
256
position = "bottom-right"
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import GeocoderControl from '@/components/search/GeocoderControl'
21
21
import { Layer , Map , Source } from 'react-map-gl'
22
22
import notify from '@/utils/notify'
23
23
import Spinner from '@/components/_shared/Spinner'
24
+ import { HideBoundaries } from '@/components/_shared/HideBoundaries'
24
25
25
26
export function LocationForm ( {
26
27
formObj,
@@ -245,6 +246,7 @@ export function LocationForm({
245
246
touchZoomRotate = { false }
246
247
initialViewState = { { zoom : 2 } }
247
248
>
249
+ < HideBoundaries />
248
250
< Source
249
251
type = "geojson"
250
252
data = { watch ( 'spatial' ) }
@@ -280,6 +282,7 @@ export function LocationForm({
280
282
dragRotate = { false }
281
283
touchZoomRotate = { false }
282
284
>
285
+ < HideBoundaries />
283
286
< GeocoderControl
284
287
mapboxAccessToken = "pk.eyJ1IjoicmVzb3VyY2V3YXRjaCIsImEiOiJjbHNueG5idGIwOXMzMmp0ZzE1NWVjZDV1In0.050LmRm-9m60lrzhpsKqNA"
285
288
position = "bottom-right"
@@ -292,7 +295,9 @@ export function LocationForm({
292
295
onClear = { ( e ) => {
293
296
setValue ( 'spatial_address' , '' )
294
297
} }
295
- initialValue = { watch ( 'spatial_address' ) ?? undefined }
298
+ initialValue = {
299
+ watch ( 'spatial_address' ) ?? undefined
300
+ }
296
301
/>
297
302
</ Map >
298
303
</ Tab . Panel >
Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ import {
7
7
MapRef ,
8
8
Marker ,
9
9
Source ,
10
+ useMap ,
10
11
} from 'react-map-gl'
11
12
import GeocoderControl from '@/components/search/GeocoderControl'
12
13
import { useQuery } from 'react-query'
13
14
import { UseFormReturn , useForm } from 'react-hook-form'
14
15
import DrawControl from '@/components/search/Draw'
15
16
import { LocationSearchFormType } from './DataFiles'
17
+ import { HideBoundaries } from '@/components/_shared/HideBoundaries'
16
18
17
19
export default function LocationSearch ( {
18
20
geojsons,
@@ -126,7 +128,6 @@ export default function LocationSearch({
126
128
}
127
129
} , [ ] )
128
130
129
- console . log ( 'cursor' , cursor )
130
131
return (
131
132
< Map
132
133
ref = { ( _map ) => {
@@ -145,6 +146,7 @@ export default function LocationSearch({
145
146
onClick = { handleMapClick }
146
147
cursor = { cursor }
147
148
>
149
+ < HideBoundaries />
148
150
< GeocoderControl
149
151
mapboxAccessToken = "pk.eyJ1IjoicmVzb3VyY2V3YXRjaCIsImEiOiJjbHNueG5idGIwOXMzMmp0ZzE1NWVjZDV1In0.050LmRm-9m60lrzhpsKqNA"
150
152
position = "bottom-right"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Dispatch, SetStateAction } from 'react'
6
6
import { SearchInput } from '@/schema/search.schema'
7
7
import { Filter } from '@/interfaces/search.interface'
8
8
import classNames from '@/utils/classnames'
9
+ import { HideBoundaries } from '../_shared/HideBoundaries'
9
10
10
11
export default function LocationSearch ( {
11
12
setFilters,
@@ -145,6 +146,7 @@ export default function LocationSearch({
145
146
dragRotate = { false }
146
147
touchZoomRotate = { false }
147
148
>
149
+ < HideBoundaries />
148
150
< GeocoderControl
149
151
mapboxAccessToken = "pk.eyJ1IjoicmVzb3VyY2V3YXRjaCIsImEiOiJjbHNueG5idGIwOXMzMmp0ZzE1NWVjZDV1In0.050LmRm-9m60lrzhpsKqNA"
150
152
position = "bottom-right"
You can’t perform that action at this time.
0 commit comments