).
```
--------------------------------
### Implement Popup with Marker
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/07-FEATURE-COMPONENTS.md
Attaches a popup to a Marker component.
```svelte
{ /* open */ }}>
Marker popup
```
--------------------------------
### Layer Interaction and Hover State Management
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/09-QUICK-START-PATTERNS.md
Implements hover and selection states using feature-state and component bindings.
```svelte
{#if hoveredFeature}
Hovering: {hoveredFeature.properties?.name}
{/if}
```
--------------------------------
### Configure ClusterOptions
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/02-TYPES.md
Configuration interface for GeoJSON source clustering.
```typescript
interface ClusterOptions {
minPoints?: number; // @default 2
maxZoom?: number;
radius?: number; // @default 50
properties?: Record;
}
```
```svelte
```
--------------------------------
### Initialize Layer Context
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/01-CONTEXT-API.md
Initializes layer and event contexts, with an optional interactive flag for mouse event handling.
```typescript
function updatedLayerContext(interactive?: boolean): {
layer: Box;
layerEvent: Box;
}
```
--------------------------------
### Using the Generic Layer Component
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/06-LAYER-COMPONENTS.md
Utilize the base Layer component for layer types that do not have dedicated specialized components.
```svelte
```
--------------------------------
### Implement RasterTileSource
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/05-SOURCE-COMPONENTS.md
Basic usage of the RasterTileSource component with a nested RasterLayer.
```svelte
```
--------------------------------
### SymbolLayer
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/06-LAYER-COMPONENTS.md
Renders text labels and icons.
```APIDOC
## SymbolLayer
### Description
Renders text labels and icons.
### Import
`import { SymbolLayer } from 'svelte-maplibre';`
### Props
- **layout** (SymbolLayerSpecification['layout']) - Required
- **paint** (SymbolLayerSpecification['paint']) - Optional
### Example
```svelte
```
```
--------------------------------
### HeatmapLayer
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/06-LAYER-COMPONENTS.md
Renders a heatmap from points.
```APIDOC
## HeatmapLayer
### Description
Renders a heatmap from points.
### Import
`import { HeatmapLayer } from 'svelte-maplibre';`
### Props
- **paint** (HeatmapLayerSpecification['paint']) - Required
### Example
```svelte
```
```
--------------------------------
### Implement GeoJSON Clustering
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/09-QUICK-START-PATTERNS.md
Configures point clustering for GeoJSON data using the cluster prop and conditional paint properties for styling clusters versus individual points.
```svelte
```
--------------------------------
### Wait for Images to Load
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/09-QUICK-START-PATTERNS.md
Use the allImagesLoaded slot prop to ensure images are ready before rendering dependent layers.
```svelte
{#if allImagesLoaded}
{/if}
```
--------------------------------
### Implement RasterDEMTileSource
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/05-SOURCE-COMPONENTS.md
Usage of the RasterDEMTileSource component paired with a Terrain component for 3D visualization.
```svelte
```
--------------------------------
### Add a map source with lifecycle handling
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/03-UTILITIES.md
Adds a source to the map, waiting for any pending removals of the same ID to complete first. The okToAdd callback should be used to verify the component is still mounted.
```typescript
function addSource(
map: Map,
sourceId: string,
source: SourceSpecification,
okToAdd: (sourceId: string) => boolean,
cb: () => void
): void
```
```typescript
import { addSource } from 'svelte-maplibre';
import { GeoJSON } from 'geojson';
const geojsonSource = {
type: 'geojson',
data: featureCollection
};
addSource(
map,
'my-source',
geojsonSource,
(id) => id === 'my-source', // Don't add if source ID changed
() => {
console.log('Source added');
}
);
```
--------------------------------
### Compare bounds with boundsEqual
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/02-TYPES.md
Compares two bounds for equality using floating-point tolerance. Requires importing LngLatBounds from maplibre-gl.
```typescript
function boundsEqual(
param: LngLatBoundsLike,
mapBounds: LngLatBounds | undefined
): { equal: boolean; bounds: LngLatBounds }
```
```typescript
import { boundsEqual } from 'svelte-maplibre';
import { LngLatBounds } from 'maplibre-gl';
const bounds = [[-74, 40], [-73, 41]];
const mapBounds = new LngLatBounds([-74, 40], [-73, 41]);
const { equal } = boundsEqual(bounds, mapBounds);
console.log(equal); // true
```
--------------------------------
### Render Markers with Popups
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/09-QUICK-START-PATTERNS.md
Displays multiple markers on a map using an each block, with associated popups for displaying location details.
```svelte
{#each locations as location (location.id)}
{location.name}
{/each}
```
--------------------------------
### Use flush to clean objects
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/03-UTILITIES.md
Demonstrates removing null and undefined properties from an object configuration.
```typescript
import { flush } from 'svelte-maplibre';
const options = {
center: [0, 0],
zoom: undefined,
pitch: 45,
bearing: null,
interactive: true
};
const clean = flush(options);
// Result: { center: [0, 0], pitch: 45, interactive: true }
```
--------------------------------
### Render Vector Tiles
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/09-QUICK-START-PATTERNS.md
Displays vector data sources with specific layers for lines and symbols.
```svelte
```
--------------------------------
### Implement Data-Driven Styling with CircleLayer
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/09-QUICK-START-PATTERNS.md
Uses MapLibre expressions to dynamically style circle layers based on feature properties like magnitude and temperature.
```svelte
```
--------------------------------
### convertBoundsToUserFormat(bounds: LngLatBounds, param: LngLatBoundsLike | undefined)
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/02-TYPES.md
Converts bounds back to the format used by the user, preserving the input format.
```APIDOC
## convertBoundsToUserFormat(bounds: LngLatBounds, param: LngLatBoundsLike | undefined)
### Description
Convert bounds back to the format used by the user (preserves input format).
### Parameters
- **bounds** (LngLatBounds) - Internal bounds object
- **param** (LngLatBoundsLike) - Original bounds format from user
### Returns
Bounds in the same format as `param` input
### Example
```typescript
// If user passed [[lng, lat], [lng, lat]], returns same format
const result1 = convertBoundsToUserFormat(bounds, [[0, 0], [10, 10]]);
// result1 → [[0, 0], [10, 10]]
// If user passed [lng, lat, lng, lat], returns same format
const result2 = convertBoundsToUserFormat(bounds, [0, 0, 10, 10]);
// result2 → [0, 0, 10, 10]
```
```
--------------------------------
### getId(prefix: string): string
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/01-CONTEXT-API.md
Generates a unique ID string with a specified prefix, useful for identifying map layers or sources.
```APIDOC
## getId(prefix: string)
### Description
Generates a unique ID with the given prefix. Uses the current timestamp to avoid ID reuse during hot module replacement.
### Parameters
- **prefix** (string) - Required - Prefix for the generated ID (e.g., 'layer', 'source')
### Returns
- **string** - Unique string ID in format `{prefix}-{incrementing number}`
```
--------------------------------
### addSource(map, sourceId, source, okToAdd, cb)
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/03-UTILITIES.md
Adds a source to the map with lifecycle handling, ensuring that if a source with the same ID is being removed, the new one is added only after removal completes.
```APIDOC
## addSource(map, sourceId, source, okToAdd, cb)
### Description
Adds a source to the map with proper handling of source replacement. If a source with the same ID is being removed, it waits for the removal to complete before adding the new one.
### Parameters
- **map** (Map) - Required - MapLibre map instance
- **sourceId** (string) - Required - Unique source identifier
- **source** (SourceSpecification) - Required - Source configuration object
- **okToAdd** (function) - Required - Callback to check if source should be added (prevents adding if component unmounted)
- **cb** (function) - Required - Callback invoked after source is added
### Returns
- **void**
```
--------------------------------
### Initialize Zoom Range Context
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/01-CONTEXT-API.md
Creates a new zoom range context that inherits unspecified limits from parent contexts.
```typescript
function updatedZoomRangeContext(
minzoom: number | undefined,
maxzoom: number | undefined
): {
originalMinZoom: number;
originalMaxZoom: number;
minzoom: number;
maxzoom: number;
}
```
--------------------------------
### Load custom images and layers
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/04-MAPLIBRE-COMPONENT.md
Registers custom images with the map and waits for them to load before rendering dependent layers.
```svelte
{#if allImagesLoaded}
{/if}
```
--------------------------------
### flush(obj)
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/03-UTILITIES.md
Removes all null and undefined values from an object to create clean configuration objects.
```APIDOC
## flush(obj)
### Description
Removes all undefined and null values from an object. This is used to create clean configuration objects for MapLibre APIs that do not accept undefined values.
### Parameters
- **obj** (Record) - Required - The object to filter.
### Returns
- **Object** - A new object with all null and undefined values removed.
### Example
```typescript
import { flush } from 'svelte-maplibre';
const options = { center: [0, 0], zoom: undefined, pitch: 45 };
const clean = flush(options);
// Result: { center: [0, 0], pitch: 45 }
```
```
--------------------------------
### FillLayer
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/06-LAYER-COMPONENTS.md
Renders filled polygons.
```APIDOC
## FillLayer
### Description
Renders filled polygons.
### Import
`import { FillLayer } from 'svelte-maplibre';`
### Props
- **paint** (FillLayerSpecification['paint']) - Required
- **layout** (FillLayerSpecification['layout']) - Optional
### Example
```svelte
{
console.log('Clicked polygon:', info.features[0].properties);
}}
/>
```
```
--------------------------------
### RasterLayer
Source: https://github.com/dimfeld/svelte-maplibre/blob/master/_autodocs/06-LAYER-COMPONENTS.md
Renders raster tiles.
```APIDOC
## RasterLayer
### Description
Renders raster tiles.
### Import
`import { RasterLayer } from 'svelte-maplibre';`
### Props
- **paint** (RasterLayerSpecification['paint']) - Optional
```