### Install Sveaflet using npm Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/pages/quick-start.md This command installs the Sveaflet library and adds it as a dependency to your project. Ensure you have Node.js and npm installed. ```bash npm install sveaflet --save ``` -------------------------------- ### Setup Sveaflet Icon Component Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Icon.md Demonstrates the basic setup for using the Icon component in Sveaflet by importing it. This is a prerequisite for utilizing any icon functionalities. ```svelte ``` -------------------------------- ### Sveaflet Event Handling with Direct Props (v0.1.0+) Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/pages/quick-start.md Demonstrates event handling in Sveaflet using direct event listener props (e.g., `onclick`) available from version 0.1.0 onwards. This simplifies event attachment compared to using Leaflet's `.on()` method. The example shows handling map clicks to display a popup. ```svelte
OpenStreetMap' }} />
``` -------------------------------- ### Sveaflet with TypeScript and Popup Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/pages/quick-start.md Shows how to use Sveaflet with TypeScript, including binding to component instances to control their state, such as opening a popup programmatically. This example is designed for client-side rendering and hides the output. ```svelte
``` -------------------------------- ### Setup Tooltip Component Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Tooltip.md Imports the Tooltip component from Sveaflet for use in Svelte applications. This is the basic setup required before using tooltips. ```svelte ``` -------------------------------- ### Initialize Leaflet Map with Interactive Elements in Sveaflet (Svelte) Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/examples/sveaflet-quick-start-guide.md This code snippet demonstrates how to set up a basic Leaflet map using Sveaflet components in a Svelte application. It imports necessary components from 'sveaflet', initializes a map with tile layers, adds markers, circles, polygons, and popups, and handles click events to update popup content. Dependencies include Leaflet and Sveaflet; inputs are configuration options for map center, zoom, and element properties; outputs include an interactive map displayed in a div. Limitations include client-side rendering as indicated by 'csr', and it assumes basic knowledge of Svelte reactivity. ```svelte
OpenStreetMap' }} /> Hello world!
I am a popup.' }} />
``` -------------------------------- ### Setup Sveaflet Map Component Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/pages/introduction.md Demonstrates the basic setup of a Sveaflet map component. It initializes a map with center coordinates and zoom level, adds an OpenStreetMap tile layer, and places a marker at a specific latitude and longitude. This requires the 'sveaflet' library. The map is contained within a div with a fixed height. ```svelte
``` -------------------------------- ### Setup Polyline Component Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Polyline.md Basic setup for importing and using the Polyline component. This snippet sets up the necessary imports without rendering output. ```svelte ``` -------------------------------- ### Setup Sveaflet Map Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Map.md This snippet demonstrates the basic setup of the Sveaflet Map component. It imports the Map component from the 'sveaflet' library and renders it within a Svelte component. ```svelte ``` -------------------------------- ### Setup SVGOverlay in Sveaflet Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/SVGOverlay.md This snippet demonstrates the basic setup for using the SVGOverlay component in a Sveaflet application. It imports the necessary SVGOverlay component from the 'sveaflet' library. ```svelte ``` -------------------------------- ### Svelte Popup Example Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Popup.md Demonstrates the basic setup and usage of the Sveaflet Popup component in a Svelte application. It utilizes the Map and TileLayer components to display a popup at a specific location. ```svelte ``` ```svelte
``` -------------------------------- ### Setup DivIcon in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/DivIcon.md Basic setup for importing the DivIcon component in a Svelte project. This snippet shows the minimal import required to use DivIcon. ```svelte ``` -------------------------------- ### Basic Setup for ImageOverlay in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/ImageOverlay.md This snippet demonstrates the initial import required for using the ImageOverlay component in a Svelte application with Sveaflet. It serves as a prerequisite for rendering image overlays on maps. No inputs or outputs are directly handled here; it focuses on module dependencies. ```svelte ``` -------------------------------- ### Setup Circle Component - Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Circle.md Basic setup for importing the Circle component from Sveaflet in a Svelte project. This is the minimal required import to use the component. ```svelte ``` -------------------------------- ### VideoOverlay with Options in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/VideoOverlay.md Example demonstrating how to use VideoOverlay with additional options like opacity, autoplay, and looping. Includes a toggle to dynamically adjust opacity. ```svelte
``` -------------------------------- ### VideoOverlay with Slot Content in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/VideoOverlay.md Example showing how to use VideoOverlay with slot content to provide multiple video sources. Includes options for interactivity and controls. ```svelte
``` -------------------------------- ### Setting up ControlAttribution Import in Sveaflet Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/ControlAttribution.md This snippet demonstrates the basic import of the ControlAttribution component from Sveaflet. It requires no additional dependencies beyond the Sveaflet library. No inputs or outputs are specified here; it's purely for setup purposes. Limitations include the need for a Svelte environment. ```svelte ``` -------------------------------- ### Setup TileLayerWMS Import - Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/TileLayerWMS.md Basic import setup for TileLayerWMS component from Sveaflet library. Required to access the WMS tile layer functionality. This import statement enables the use of TileLayerWMS component in Svelte applications. ```svelte ``` -------------------------------- ### Sveaflet: Control Layers with Base and Overlay Groups Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/examples/layer-groups-and-layers-control.md This example showcases how to use Sveaflet's ControlLayers to manage different types of map layers, including base tile layers and overlay layer groups with markers and popups. It requires the sveaflet library and basic HTML structure for map rendering. ```svelte
OpenStreetMap' }} checked={true} /> OpenStreetMap contributors, Tiles style by Humanitarian OpenStreetMap Team hosted by OpenStreetMap France' }} /> OpenStreetMap contributors, SRTM | Map style: © OpenTopoMap (CC-BY-SA)' }} />
``` -------------------------------- ### Default VideoOverlay Usage in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/VideoOverlay.md Example of a basic VideoOverlay implementation with a map, tile layer, and video overlay. The video is displayed over specified bounds with default options. ```svelte
``` -------------------------------- ### Basic Setup for Rectangle in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Rectangle.md This snippet demonstrates the initial import of the Rectangle component from Sveaflet. It is used as a foundational step before integrating into a map. No map rendering occurs here; dependencies include Sveaflet library. Input is the import statement; output is the component availability. ```svelte ``` -------------------------------- ### Setting up TileLayer Import in Sveaflet Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/TileLayer.md This snippet demonstrates the basic import of the TileLayer component from Sveaflet for use in Svelte applications. It requires the Sveaflet library installed and focuses on the script section without rendering output. No additional dependencies beyond Sveaflet are needed; it prepares the component for mapping functionalities but does not handle actual rendering. ```svelte ``` -------------------------------- ### Sveaflet Event Handling with Leaflet's .on() Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/pages/quick-start.md Illustrates how to handle map click events using Leaflet's standard event listener API (`.on()`) within a Sveaflet application. This approach is used for versions prior to 0.1.0 where direct event props were not available. It binds to the map instance to attach the listener. ```svelte
OpenStreetMap' }} />
``` -------------------------------- ### Custom DivIcon with Options in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/DivIcon.md Example of customizing the DivIcon with options, including className for styling. This snippet shows how to apply custom styles to the DivIcon. ```svelte
``` -------------------------------- ### Importing ControlLayers in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/ControlLayers.md This snippet demonstrates the basic import of the ControlLayers component from the Sveaflet library. It requires no additional dependencies beyond Sveaflet installation. No specific inputs or outputs; used as a prerequisite for using the component in Svelte applications. ```svelte ``` -------------------------------- ### Setup Marker Component in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Marker.md This code snippet demonstrates how to import and set up the Marker component from the sveaflet library in a Svelte application. It requires the sveaflet package as a dependency. The input is none, and it outputs a prepared component for use in maps. Limitation: Assumes Svelte environment with CSR support. ```svelte ``` -------------------------------- ### Create Polygon with Options in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Polygon.md This example shows how to configure a Polygon with options such as color. The options are controlled via a radio button, allowing changing the color of the polygon dynamically. ```svelte
Red Green Blue
``` -------------------------------- ### Default SVGOverlay Implementation in Sveaflet Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/SVGOverlay.md This example shows a default implementation of the SVGOverlay component within a Sveaflet map. It includes a TileLayer for the base map and an SVGOverlay with basic rectangular shapes defined within its bounds and viewBox. ```svelte
``` -------------------------------- ### Default ImageOverlay Usage in Svelte with Sveaflet Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/ImageOverlay.md This example shows how to create a map with a tile layer and overlay a single image using ImageOverlay, specifying URL and bounds. It requires Sveaflet imports and a container div for rendering. The bounds define the geographic area; the image is displayed at full opacity by default, with no additional options. ```svelte
``` -------------------------------- ### Default Circle Usage - Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Circle.md Example of creating a default circle on a map with basic configuration. Includes Map and TileLayer setup for context. ```svelte
``` -------------------------------- ### Default DivIcon Usage in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/DivIcon.md Example of using the default DivIcon component within a Map and Marker setup. This snippet demonstrates the basic integration with Leaflet's Map and TileLayer. ```svelte
``` -------------------------------- ### Hiding Default Zoom and Adding Custom ControlZoom in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/ControlZoom.md This example disables the built-in map zoom control via options and manually adds a custom ControlZoom component. It uses the same map setup with TileLayer for visualization. Purpose is to override defaults; inputs are map options like zoomControl: false, outputs provide manual zoom functionality without built-in controls. ```svelte
``` -------------------------------- ### Sveaflet: LayerGroup with Multiple Interactive Shapes and Popups Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/examples/layer-groups-and-layers-control.md This Sveaflet example demonstrates grouping various interactive map shapes (Marker, Circle, CircleMarker, Polygon, Polyline, Rectangle) within a LayerGroup. It includes functionality to programmatically open popups associated with these shapes using Svelte's reactive features and event handling. Dependencies include sveaflet, svelte, and flowbite-svelte for UI components. ```svelte
``` -------------------------------- ### LayerGroup Setup - Svelte Import Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/LayerGroup.md Basic import statement for LayerGroup component from sveaflet library. Required for all LayerGroup functionality including grouping multiple map layers together. ```svelte ``` -------------------------------- ### Create Tooltip with Dynamic Options Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Tooltip.md Creates a tooltip with dynamically bound content using Svelte reactivity. Integrates with Flowbite-Svelte input components for real-time updates. ```svelte
``` -------------------------------- ### DivIcon with Slot Content in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/DivIcon.md Example of using the DivIcon with custom slot content. This snippet demonstrates how to insert custom HTML content inside the DivIcon. ```svelte
DivIcon
``` -------------------------------- ### TileLayerWMS with Dynamic Options - Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/TileLayerWMS.md Advanced TileLayerWMS implementation featuring interactive controls for dynamic opacity adjustment. Integrates Flowbite-Svelte components including Label and Toggle for user interaction. Demonstrates reactive state management with Svelte $state and conditional rendering of WMS layer options. ```svelte
``` -------------------------------- ### Default GeoJSON Map Setup in Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/GeoJSON.md Shows how to set up a basic map with a TileLayer and empty GeoJSON component. The map is centered on specific coordinates with a default zoom level. ```svelte
``` -------------------------------- ### Interactive Map with Sveaflet Components in Svelte Source: https://context7.com/grayfrost/sveaflet/llms.txt This example initializes a Leaflet map using the Sveaflet Map component, which serves as the root container providing context to child components like TileLayer, Marker, and Popup. It demonstrates reactive zoom control with Svelte 5 $state and $effect, event handling for clicks and zoom changes, and binding to the map instance for programmatic control. Dependencies include the 'sveaflet' library; inputs are options props and latLng for markers; outputs include bound instance and emitted events; limitations involve requiring a valid tile URL and proper Svelte context propagation. ```svelte
OpenStreetMap' }} />
``` -------------------------------- ### Display WMS Layers in Sveaflet Map Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/examples/wms.md This Svelte component demonstrates how to integrate multiple Web Map Service (WMS) layers into a Sveaflet map. It utilizes the `Map`, `TileLayerWMS`, and `ControlLayers` components from the 'sveaflet' library. The component allows users to switch between different WMS layers, including topography and place overlays, by configuring the `url` and `options.layers` properties of `TileLayerWMS`. ```svelte
``` -------------------------------- ### Create Default Tooltip Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/Tooltip.md Creates a basic tooltip on a map at specified coordinates with static content. Requires Map, TileLayer, and Tooltip components from Sveaflet. ```svelte
``` -------------------------------- ### Configure Image and Video Overlays with Sveaflet Source: https://context7.com/grayfrost/sveaflet/llms.txt Implementation of ImageOverlay and VideoOverlay components with bounds positioning and event handling. Includes opacity controls, error handling, and interactive click events. Dependencies include Sveaflet's Map, TileLayer, ImageOverlay, VideoOverlay, and Rectangle components. ```svelte
{#if showImage} console.log('Image overlay clicked')} /> {/if} {#if showVideo} { console.log('Video overlay clicked'); toggleVideo(); }} /> {/if}
``` -------------------------------- ### Default TileLayerWMS Usage - Svelte Source: https://github.com/grayfrost/sveaflet/blob/main/src/routes/docs/components/TileLayerWMS.md Basic TileLayerWMS implementation with Map component integration. Creates a map with centered coordinates and zoom level, then adds a WMS tile layer with TOPO-OSM-WMS service. Demonstrates essential props including url and options for layer configuration. ```svelte
```