svelte-maplibre
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -16,2 +16,4 @@ import type { Map, Marker } from 'maplibre-gl'; | ||
loadedImages: Writable<Set<string>>; | ||
minzoom: Writable<number>; | ||
maxzoom: Writable<number>; | ||
} | ||
@@ -21,2 +23,3 @@ export declare function markerHoverContext(): Readable<boolean> | undefined; | ||
export declare function mapContext(): MapContext; | ||
export declare function setMapContext(context: MapContext): MapContext; | ||
export declare function createMapContext(): MapContext; | ||
@@ -29,2 +32,8 @@ export interface UpdatedContext<TYPE> extends MapContext { | ||
export declare function updatedMarkerContext(): UpdatedContext<Marker>; | ||
export declare function updatedZoomRangeContext(initialMinZoom: number | undefined, initialMaxZoom: number | undefined): { | ||
originalMinZoom: Writable<number>; | ||
originalMaxZoom: Writable<number>; | ||
minzoom: Writable<number>; | ||
maxzoom: Writable<unknown>; | ||
}; | ||
export declare function eventTracker(mouseEvent: Writable<LayerClickInfo | null>): void; |
@@ -21,2 +21,5 @@ import { getContext, setContext } from 'svelte'; | ||
} | ||
export function setMapContext(context) { | ||
return setContext(MAP_CONTEXT_KEY, context); | ||
} | ||
export function createMapContext() { | ||
@@ -30,2 +33,4 @@ return setContext(MAP_CONTEXT_KEY, { | ||
loadedImages: writable(new Set()), | ||
minzoom: writable(0), | ||
maxzoom: writable(24), | ||
}); | ||
@@ -70,2 +75,18 @@ } | ||
} | ||
export function updatedZoomRangeContext(initialMinZoom, initialMaxZoom) { | ||
let currentContext = mapContext(); | ||
let minzoom = writable(initialMinZoom); | ||
let maxzoom = writable(); | ||
setContext(MAP_CONTEXT_KEY, { | ||
...currentContext, | ||
minzoom: readableFromWritable(minzoom), | ||
maxzoom: readableFromWritable(maxzoom), | ||
}); | ||
return { | ||
originalMinZoom: currentContext.minzoom, | ||
originalMaxZoom: currentContext.maxzoom, | ||
minzoom, | ||
maxzoom, | ||
}; | ||
} | ||
export function eventTracker(mouseEvent) { } |
import type { ExpressionSpecification } from 'maplibre-gl'; | ||
/** Use an image loaded into the map, falling back to another image if it does not exist. */ | ||
export declare function imageWithFallback(imageId: string | ExpressionSpecification, fallbackId: string): ExpressionSpecification; | ||
/** Create an interpolation that changes with the map's zoom level. */ | ||
export declare function zoomTransition(start: number, startValue: number | ExpressionSpecification, end: number, endValue: number | ExpressionSpecification): ExpressionSpecification; |
@@ -5,1 +5,6 @@ /** Use an image loaded into the map, falling back to another image if it does not exist. */ | ||
} | ||
/** Create an interpolation that changes with the map's zoom level. */ | ||
export function zoomTransition(start, startValue, end, endValue) { | ||
// let actualStart = typeof startValue === 'number' ? ['literal', startValue]; | ||
return ['interpolate', ['linear'], ['zoom'], start, startValue, end, endValue]; | ||
} |
import type { ExpressionSpecification } from 'maplibre-gl'; | ||
export declare function combineFilters(join: 'all' | 'any', ...filters: (ExpressionSpecification | null | undefined)[]): ExpressionSpecification | undefined; | ||
/** Return an expression that returns a value based on whether the feature is a cluster or an individual point. */ | ||
export declare function isClusterFilter(matchClusters: boolean | undefined): ExpressionSpecification | undefined; | ||
/** Return an expression that returns a value based on whether the feature is hovered. */ | ||
export declare function hoverStateFilter(defaultValue: string | number | boolean, hoverValue: string | number | boolean): ExpressionSpecification; | ||
/** A function that returns if a layer is a text layer, and optionally if it belongs to a particular source. */ | ||
export declare function isTextLayer(layer: maplibregl.LayerSpecification, source?: string): boolean; |
@@ -28,2 +28,3 @@ export function combineFilters(join, ...filters) { | ||
} | ||
/** Return an expression that returns a value based on whether the feature is a cluster or an individual point. */ | ||
export function isClusterFilter(matchClusters) { | ||
@@ -36,4 +37,11 @@ return matchClusters === true | ||
} | ||
/** Return an expression that returns a value based on whether the feature is hovered. */ | ||
export function hoverStateFilter(defaultValue, hoverValue) { | ||
return ['case', ['boolean', ['feature-state', 'hover'], false], hoverValue, defaultValue]; | ||
} | ||
/** A function that returns if a layer is a text layer, and optionally if it belongs to a particular source. */ | ||
export function isTextLayer(layer, source) { | ||
return (layer.type === 'symbol' && | ||
(!source || layer.source === source) && | ||
!!layer.layout?.['text-field']); | ||
} |
@@ -21,2 +21,3 @@ export { default as AttributionControl } from './AttributionControl.svelte'; | ||
export { default as SymbolLayer } from './SymbolLayer.svelte'; | ||
export { default as ZoomRange } from './ZoomRange.svelte'; | ||
export { getId, mapContext, updatedSourceContext, updatedLayerContext, updatedMarkerContext, } from './context.js'; | ||
@@ -23,0 +24,0 @@ export * from './expressions.js'; |
@@ -21,2 +21,3 @@ export { default as AttributionControl } from './AttributionControl.svelte'; | ||
export { default as SymbolLayer } from './SymbolLayer.svelte'; | ||
export { default as ZoomRange } from './ZoomRange.svelte'; | ||
export { getId, mapContext, updatedSourceContext, updatedLayerContext, updatedMarkerContext, } from './context.js'; | ||
@@ -23,0 +24,0 @@ export * from './expressions.js'; |
@@ -24,2 +24,3 @@ import { SvelteComponentTyped } from "svelte"; | ||
/** Set to true or a position to add all the standard controls. */ standardControls?: boolean | import("maplibre-gl").ControlPosition | undefined; | ||
/** Filter the map's builtin layers, hiding any for which this function returns false. */ filterLayers?: ((layer: maplibregl.LayerSpecification) => boolean) | undefined; | ||
}; | ||
@@ -26,0 +27,0 @@ events: { |
@@ -7,4 +7,8 @@ import { SvelteComponentTyped } from "svelte"; | ||
filter?: maplibregl.ExpressionSpecification | undefined; | ||
/** How to calculate the coordinates of the marker. | ||
* @default Calls turf.center` on the feature. */ markerLngLat?: ((feature: Feature) => [number, number]) | undefined; | ||
/** If interactive is true (default), the markers will render as `button`. If not, | ||
* they will render as `div` elements. */ interactive?: boolean | undefined; | ||
minzoom?: number | undefined; | ||
maxzoom?: number | undefined; | ||
}; | ||
@@ -19,3 +23,3 @@ events: { | ||
feature: Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>; | ||
center: any; | ||
position: any; | ||
}; | ||
@@ -22,0 +26,0 @@ }; |
{ | ||
"name": "svelte-maplibre", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Svelte bindings for MapLibre", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76555
57
922