Skip to content

Commit 24b992d

Browse files
committed
Render filter as icons. #10
1 parent 829fba5 commit 24b992d

13 files changed

+27
-38
lines changed

web/public/filters/bus_gate.svg

-5
This file was deleted.

web/public/filters/bus_gate_icon.gif

7.65 KB
Loading

web/public/filters/no_entry.svg

-5
This file was deleted.

web/public/filters/no_entry_icon.gif

6.54 KB
Loading

web/public/filters/school_street.svg

-5
This file was deleted.
9.28 KB
Loading

web/public/filters/walk_cycle_only.svg

-6
This file was deleted.
8.69 KB
Loading

web/src/App.svelte

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
// @ts-ignore ErrorEvent isn't exported
8686
console.log(e.detail.error);
8787
}}
88+
images={[
89+
{ id: "walk_cycle_only", url: "/filters/walk_cycle_only_icon.gif" },
90+
{ id: "no_entry", url: "/filters/no_entry_icon.gif" },
91+
{ id: "bus_gate", url: "/filters/bus_gate_icon.gif" },
92+
{ id: "school_street", url: "/filters/school_street_icon.gif" },
93+
]}
8894
>
8995
<div bind:this={mapDiv} />
9096
{#if $mode.mode == "title"}

web/src/ModalFilterLayer.svelte

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<script lang="ts">
2-
import { CircleLayer, GeoJSON } from "svelte-maplibre";
2+
import { GeoJSON, SymbolLayer } from "svelte-maplibre";
33
import { app, mutationCounter } from "./stores";
44
55
// TODO Runes would make this so nicer. The > 0 part is a hack...
66
$: gj = $mutationCounter > 0 ? JSON.parse($app!.renderModalFilters()) : null;
77
</script>
88

99
<GeoJSON data={gj}>
10-
<CircleLayer
11-
paint={{
12-
"circle-radius": 15,
13-
"circle-color": "black",
10+
<SymbolLayer
11+
layout={{
12+
"icon-image": ["get", "filter_kind"],
13+
"icon-allow-overlap": true,
14+
"icon-size": 0.1,
1415
}}
1516
/>
1617
</GeoJSON>

web/src/RenderNeighbourhood.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { showBasemap } from "./stores";
55
66
export let gjInput: FeatureCollection;
7-
// When disabled, can't click lines or circles, no slots, no hoverCursor
7+
// When disabled, can't click lines or filters, no slots, no hoverCursor
88
export let interactive = true;
99
export let onClickLine = (f: Feature) => {};
1010

web/src/edit/ChangeModalFilter.svelte

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
style="width: 100%"
4141
disabled={filterType == name}
4242
on:click={() => (filterType = name)}
43-
><img src={`/filters/${name}.svg`} alt={label} />{label}</button
43+
><img
44+
src={`/filters/${name}_icon.gif`}
45+
width="80"
46+
alt={label}
47+
/><br/>{label}</button
4448
>
4549
</div>
4650
{/each}

web/src/edit/NeighbourhoodMode.svelte

+9-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
} from "geojson";
88
import type { MapMouseEvent } from "maplibre-gl";
99
import { onDestroy } from "svelte";
10-
import { CircleLayer, GeoJSON, Popup } from "svelte-maplibre";
10+
import { GeoJSON, Popup, SymbolLayer } from "svelte-maplibre";
1111
import { notNull } from "../common";
1212
import ManageSavefiles from "../ManageSavefiles.svelte";
1313
import RenderNeighbourhood from "../RenderNeighbourhood.svelte";
@@ -65,10 +65,8 @@
6565
6666
function deleteFilter(e) {
6767
let f = e.detail.features[0];
68-
if (f.properties!.kind == "modal_filter") {
69-
$app!.deleteModalFilter(f.properties!.road);
70-
$mutationCounter++;
71-
}
68+
$app!.deleteModalFilter(f.properties!.road);
69+
$mutationCounter++;
7270
}
7371
7472
function onKeyDown(e: KeyboardEvent) {
@@ -222,15 +220,16 @@
222220
</div>
223221
</RenderNeighbourhood>
224222
<GeoJSON data={modalFilterGj} generateId>
225-
<CircleLayer
226-
paint={{
227-
"circle-radius": 15,
228-
"circle-color": "black",
223+
<SymbolLayer
224+
layout={{
225+
"icon-image": ["get", "filter_kind"],
226+
"icon-allow-overlap": true,
227+
"icon-size": 0.1,
229228
}}
230229
on:click={deleteFilter}
231230
>
232231
<Popup openOn="hover">Click to delete</Popup>
233-
</CircleLayer>
232+
</SymbolLayer>
234233
</GeoJSON>
235234
{#if addingMultipleFilters}
236235
<FreehandLine map={notNull($map)} on:done={gotFreehandLine} />

0 commit comments

Comments
 (0)