|
1 | 1 | <script> |
2 | 2 | import { base } from '$app/paths'; |
| 3 | + import Icon from "@iconify/svelte"; |
3 | 4 | import { MapLibre, Popup, Marker } from 'svelte-maplibre'; |
4 | 5 | import PopRock from './PopRock.svelte'; |
5 | 6 | import { COLOR_CLASSES, STATION_TYPE_COLORS } from '$lib/colors'; |
6 | 7 |
|
| 8 | + const MAP_STYLES = { |
| 9 | + "light": "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json", |
| 10 | + "satellite": "https://tiles.stadiamaps.com/styles/alidade_satellite.json", |
| 11 | + } |
| 12 | +
|
7 | 13 | let { |
8 | | - selectedStations = $bindable([]), |
| 14 | + selectedStations = [], |
| 15 | + selectedStationsColorIndex = [], |
9 | 16 | toggleStation = () => {}, |
10 | 17 | } = $props(); |
11 | 18 |
|
12 | 19 | let stations = $state(); |
13 | 20 |
|
| 21 | + let mapStyle = $state(MAP_STYLES.light); |
| 22 | +
|
14 | 23 | $effect(() => { |
15 | 24 | fetch(`${base}/data/station_locations.json`).then(d => d.json()).then(d => { |
16 | 25 | stations = d; |
|
26 | 35 | center={[-76.6, 39.3]} |
27 | 36 | zoom={11} |
28 | 37 | standardControls |
29 | | - style="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json" |
| 38 | + style={mapStyle} |
30 | 39 | class="w-full h-full min-h-96 overflow-hidden" |
31 | 40 | cooperativeGestures |
32 | 41 | > |
|
37 | 46 | class=" |
38 | 47 | rounded-full cursor-pointer border border-black |
39 | 48 | {selectedStations.includes(properties.station_id) |
40 | | - ? `w-5 h-5 ${COLOR_CLASSES[selectedStations.indexOf(properties.station_id)]}` |
| 49 | + ? `w-5 h-5 ${COLOR_CLASSES[selectedStationsColorIndex[selectedStations.indexOf(properties.station_id)]]}` |
41 | 50 | : `w-3 h-3 ${STATION_TYPE_COLORS[properties.station_type]}` |
42 | 51 | } |
43 | 52 | " |
|
51 | 60 | </MapLibre> |
52 | 61 | <div |
53 | 62 | class=" |
54 | | - absolute bottom-12 pointer-events-none |
55 | | - bg-white border-gray-300 border p-2 flex flex-row items-center gap-2 |
| 63 | + absolute bottom-12 |
| 64 | + bg-white border-gray-300 border p-2 flex flex-row items-center gap-4 |
56 | 65 | " |
57 | 66 | > |
58 | | - <span>Station Type:</span> |
59 | | - {#each Object.keys(STATION_TYPE_COLORS) as t} |
60 | | - <div class="flex flex-row items-center gap-1"> |
61 | | - <div class="w-3 h-3 rounded-full border border-black {STATION_TYPE_COLORS[t]}"></div> |
62 | | - <span>{t}</span> |
63 | | - </div> |
64 | | - {/each} |
| 67 | + <div class="flex flex-row items-center gap-2"> |
| 68 | + <span>Base map:</span> |
| 69 | + <button |
| 70 | + disabled={mapStyle === MAP_STYLES.satellite} |
| 71 | + onclick={() => {mapStyle=MAP_STYLES.satellite}} |
| 72 | + class=" |
| 73 | + border rounded-sm p-1 |
| 74 | + {mapStyle === MAP_STYLES.satellite ? 'border-gray-400 text-gray-400 cursor-not-allowed' : 'border-blue-400 text-blue-400 shadow cursor-pointer'} |
| 75 | + " |
| 76 | + > |
| 77 | + <Icon class="" icon="gis:satellite-earth" width=24 height=24 /> |
| 78 | + </button> |
| 79 | + <button |
| 80 | + disabled={mapStyle === MAP_STYLES.light} |
| 81 | + onclick={() => {mapStyle=MAP_STYLES.light}} |
| 82 | + class=" |
| 83 | + border rounded-sm p-1 |
| 84 | + {mapStyle === MAP_STYLES.light ? 'border-gray-400 text-gray-400 cursor-not-allowed' : 'border-blue-400 text-blue-400 shadow cursor-pointer'} |
| 85 | + " |
| 86 | + > |
| 87 | + <Icon class="" icon="emojione-monotone:world-map" width=24 height=24 /> |
| 88 | + </button> |
| 89 | + </div> |
| 90 | + <div class="flex flex-row items-center gap-2"> |
| 91 | + <span>Station Type:</span> |
| 92 | + {#each Object.keys(STATION_TYPE_COLORS) as t} |
| 93 | + <div class="flex flex-row items-center gap-1"> |
| 94 | + <div class="w-3 h-3 rounded-full border border-black {STATION_TYPE_COLORS[t]}"></div> |
| 95 | + <span>{t}</span> |
| 96 | + </div> |
| 97 | + {/each} |
| 98 | + </div> |
65 | 99 | </div> |
66 | 100 | </div> |
0 commit comments