Skip to content

Commit b235a41

Browse files
committed
Use ModalFilterLayer in another place
1 parent 3bbf5af commit b235a41

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

web/src/ModalFilterLayer.svelte

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
$: gj = $mutationCounter > 0 ? JSON.parse($app!.renderModalFilters()) : null;
88
</script>
99

10-
<GeoJSON data={gj}>
10+
<GeoJSON data={gj} generateId>
1111
<SymbolLayer
1212
{...layerId("modal-filters")}
1313
layout={{
1414
"icon-image": ["get", "filter_kind"],
1515
"icon-allow-overlap": true,
1616
"icon-size": 0.1,
1717
}}
18-
/>
18+
on:click
19+
>
20+
<slot />
21+
</SymbolLayer>
1922
</GeoJSON>

web/src/edit/NeighbourhoodMode.svelte

+6-18
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
} from "geojson";
88
import type { MapMouseEvent } from "maplibre-gl";
99
import { onDestroy } from "svelte";
10-
import { GeoJSON, SymbolLayer, type LayerClickInfo } from "svelte-maplibre";
11-
import { layerId, notNull, Popup } from "../common";
10+
import { type LayerClickInfo } from "svelte-maplibre";
11+
import { notNull, Popup } from "../common";
1212
import ManageSavefiles from "../ManageSavefiles.svelte";
1313
import RenderNeighbourhood from "../RenderNeighbourhood.svelte";
1414
import SplitComponent from "../SplitComponent.svelte";
1515
import { app, map, mode, mutationCounter } from "../stores";
1616
import ChangeModalFilter from "./ChangeModalFilter.svelte";
1717
import FreehandLine from "./FreehandLine.svelte";
18+
import ModalFilterLayer from "../ModalFilterLayer.svelte";
1819
1920
// Caller is responsible for doing app.setCurrentNeighbourhood
2021
@@ -27,7 +28,6 @@
2728
let boundary: Feature<Polygon> | null;
2829
2930
let gjInput: FeatureCollection;
30-
let modalFilterGj: FeatureCollection;
3131
$: rerender($mutationCounter);
3232
3333
function rerender(_x: number) {
@@ -40,8 +40,6 @@
4040
undoLength = gjInput.undo_length;
4141
// @ts-ignore These foreign members exist
4242
redoLength = gjInput.redo_length;
43-
44-
modalFilterGj = JSON.parse($app!.renderModalFilters());
4543
}
4644
4745
$: if (addingFilter) {
@@ -218,19 +216,9 @@
218216
</Popup>
219217
</div>
220218
</RenderNeighbourhood>
221-
<GeoJSON data={modalFilterGj} generateId>
222-
<SymbolLayer
223-
{...layerId("modal-filters")}
224-
layout={{
225-
"icon-image": ["get", "filter_kind"],
226-
"icon-allow-overlap": true,
227-
"icon-size": 0.1,
228-
}}
229-
on:click={deleteFilter}
230-
>
231-
<Popup openOn="hover">Click to delete</Popup>
232-
</SymbolLayer>
233-
</GeoJSON>
219+
<ModalFilterLayer on:click={deleteFilter}>
220+
<Popup openOn="hover">Click to delete</Popup>
221+
</ModalFilterLayer>
234222
{#if addingMultipleFilters}
235223
<FreehandLine map={notNull($map)} on:done={gotFreehandLine} />
236224
{/if}

0 commit comments

Comments
 (0)