feat: added custom layer editor to tiles panel#354
feat: added custom layer editor to tiles panel#354nilsnolde merged 8 commits intovalhalla:masterfrom
Conversation
|
Preview is ready! 🚀 You can view it here: https://valhalla-app-tests.gis-ops.com/354 |
|
remember to un-draft PRs when you want to be reviewed! if it is ready, then we're missing a real proof, e.g. providing a style.json for some custom layer. |
nilsnolde
left a comment
There was a problem hiding this comment.
this is really cool! cc @chrstnbwnkl
one change: unless "Append Valhalla layers" is active, the new button shouldn't be active IMO, bcs that's a no-op.
|
|
||
| export const CustomLayerEditor = () => { | ||
| const { mainMap } = useMap(); | ||
| const addLayer = useCustomLayersStore((state) => state.addLayer); |
There was a problem hiding this comment.
We don't want to introduce new stores to the project, the old "directions", "isochrone" stores are artifacts from redux.
Usage of zustand stores in this component is totally unnecessary.
src/stores/custom-layers-store.ts
Outdated
There was a problem hiding this comment.
This store shouldn't be exist at all.
| const addLayer = useCustomLayersStore((state) => state.addLayer); | ||
| const layers = useCustomLayersStore((state) => state.layers); | ||
| const [open, setOpen] = useState(false); | ||
| const [json, setJson] = useState(''); |
There was a problem hiding this comment.
let's call it value or jsonValue
| }; | ||
|
|
||
| return ( | ||
| <div className="pb-1"> |
There was a problem hiding this comment.
I don't think this div is in the correct place. Where we are adding the padding? To the content of dialog, or to the trigger?
|
@nilsnolde @mustaphaturhan here i have tried to implement the changes suggested Also i've updated the tests accordingly. |
nilsnolde
left a comment
There was a problem hiding this comment.
nice, thanks!
tiny nit: once I add a custom layer and disable Valhalla layers, the "add" button is still active. that's just a small nit, meaning if it's quick to do, pls do, but if it's more than 2 lines of code, just don't:)
Thanks for the nit! I went ahead and fixed it. |
🛠️ Fixes Issue
Closes #323
👨💻 Changes proposed
valhalla-tilessurvive the Valhalla source being toggled off and back on📷 Screenshots
Before (standard tiles)
After (custom layer added)
Layer definition used above:
{ "id": "edges-highlight", "type": "line", "source": "valhalla-tiles", "source-layer": "edges", "paint": { "line-color": "#ff0000", "line-width": 2 } }This highlights all the edges in red.
📄 Note to reviewers
AI Contribution:
I've used AI assistance to help me write most of the code & for debugging the code.
I've reviewed every change, ran all the tests myself, and manually verified the feature works properly.