| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | <script lang="ts"> | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * The 'MaplibreMap' maps various event sources onto MapLibre. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * As it replaces the old 'MinimapObj' onto MapLibre and the existing codebase, this is sometimes a bit awkward | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   import { onMount } from "svelte" | 
					
						
							|  |  |  |   import { Map } from "@onsvisual/svelte-maps" | 
					
						
							|  |  |  |   import type { Map as MaplibreMap } from "maplibre-gl" | 
					
						
							| 
									
										
										
										
											2023-06-18 00:52:26 +02:00
										 |  |  |   import type {Readable, Writable} from "svelte/store" | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   import { AvailableRasterLayers } from "../../Models/RasterLayers" | 
					
						
							| 
									
										
										
										
											2023-06-18 00:52:26 +02:00
										 |  |  |   import {writable} from "svelte/store"; | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Beware: this map will _only_ be set by this component | 
					
						
							|  |  |  |    * It should thus be treated as a 'store' by external parties | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   export let map: Writable<MaplibreMap> | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-16 03:27:49 +02:00
										 |  |  |   export let attribution = false | 
					
						
							| 
									
										
										
										
											2023-06-18 00:52:26 +02:00
										 |  |  |   export let center: Readable<{ lng: number ,lat : number }> = writable({lng: 0, lat: 0}) | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   onMount(() => { | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |     $map.on("load", function () { | 
					
						
							|  |  |  |       $map.resize() | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  |   const styleUrl = AvailableRasterLayers.maplibre.properties.url | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | </script> | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | <main> | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   <Map | 
					
						
							|  |  |  |     bind:center | 
					
						
							|  |  |  |     bind:map={$map} | 
					
						
							|  |  |  |     {attribution} | 
					
						
							|  |  |  |     css="./maplibre-gl.css" | 
					
						
							|  |  |  |     id="map" | 
					
						
							|  |  |  |     location={{ lng: 0, lat: 0, zoom: 0 }} | 
					
						
							|  |  |  |     maxzoom="24" | 
					
						
							|  |  |  |     style={styleUrl} | 
					
						
							|  |  |  |   /> | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | </main> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style> | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   main { | 
					
						
							|  |  |  |     width: 100%; | 
					
						
							|  |  |  |     height: 100%; | 
					
						
							|  |  |  |     position: relative; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-03-11 02:37:07 +01:00
										 |  |  | </style> |