-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from kartoza/map
Update styles of map
- Loading branch information
Showing
7 changed files
with
134 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
django_project/minisass_frontend/src/components/Map/Layer/MinisassLayer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { FormControlLabel } from "@mui/material"; | ||
import Checkbox from "@mui/material/Checkbox"; | ||
import maplibregl from "maplibre-gl"; | ||
import { hideLayer, showLayer } from "../utils"; | ||
|
||
interface Interface { | ||
map: maplibregl.Map, | ||
} | ||
|
||
export const minisassObservationId = 'MiniSASS Observations' | ||
|
||
/** | ||
* MiniSASS Layer component | ||
*/ | ||
export default function MinisassLayer({ map }: Interface) { | ||
const [active, setActive] = useState<boolean>(true); | ||
const disabled = false | ||
|
||
/** First initiate */ | ||
useEffect(() => { | ||
map.getStyle().layers.map(layer => { | ||
if (layer.source === minisassObservationId) { | ||
if (active) { | ||
showLayer(map, layer.id) | ||
} else { | ||
hideLayer(map, layer.id) | ||
} | ||
} | ||
}) | ||
}, [active]); | ||
|
||
return <> | ||
<FormControlLabel | ||
disabled={disabled} | ||
control={ | ||
<Checkbox | ||
checked={active} | ||
onChange={evt => { | ||
setActive(!active) | ||
}}/> | ||
} | ||
label={'miniSASS Observations'} | ||
/> | ||
<br/> | ||
</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 1 addition & 10 deletions
11
django_project/minisass_frontend/src/pages/Map/config/overlay.config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
[ | ||
{ | ||
"name": "miniSASS Observations", | ||
"tiles": [ | ||
"https://minisass.org/geoserver/wms?LAYERS=miniSASS%3Aminisass_observations&TRANSPARENT=TRUE&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A3857&BBOX={bbox-epsg-3857}&WIDTH=512&HEIGHT=512" | ||
], | ||
"type": "raster", | ||
"activeByDefault": true | ||
} | ||
] | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters