@osm-editor-kit/osm-maplibre 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # `@osm-editor-kit/osm-maplibre`
2
+
3
+ **Status:** First npm **alpha** (`0.1.0-alpha.0`). Publish with `bun run packages:release -- --publish-only` after `npm login`.
4
+
5
+ ## What it does
6
+
7
+ MapLibre helpers for OSM editor maps: a patched OpenFreeMap Positron basemap (null-safe filters, custom overlay anchor), metre-based line width/offset paint expressions, and focus styling for active vs muted layers.
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import {
13
+ OPENFREEMAP_POSITRON_STYLE,
14
+ OPENFREEMAP_POSITRON_IMAGERY_USED,
15
+ MAP_CUSTOM_CONTENT_ANCHOR_LAYER_ID,
16
+ lineWidthFromMeters,
17
+ lineOffsetFromMeters,
18
+ focusCaseColor,
19
+ focusCaseOpacity,
20
+ metersPerPixel,
21
+ buildOpenFreeMapPositronStyle,
22
+ patchOpenFreeMapStyle,
23
+ } from '@osm-editor-kit/osm-maplibre'
24
+
25
+ // Default basemap for <Map mapStyle={…} />
26
+ const style = OPENFREEMAP_POSITRON_STYLE
27
+
28
+ // Stack app layers above the basemap (react-map-gl `beforeId`)
29
+ <Layer id="my-overlay" beforeId={MAP_CUSTOM_CONTENT_ANCHOR_LAYER_ID} … />
30
+
31
+ // Line width/offset from feature properties in metres (zoom-aware)
32
+ 'line-width': lineWidthFromMeters('roadWidthM')
33
+ 'line-width': lineWidthFromMeters('roadWidthM', { extraMeters: 2 }) // wider hit target
34
+ 'line-offset': lineOffsetFromMeters('parentRoadWidthM', 0.5, {
35
+ sign: ['case', ['==', ['get', 'side'], 'left'], -1, 1],
36
+ })
37
+
38
+ // Active vs muted styling when focus filter matches
39
+ 'line-color': focusCaseColor(['==', ['get', 'infra'], 'car'], '#2563eb')
40
+ 'line-opacity': focusCaseOpacity(['==', ['get', 'infra'], 'car'], 0.55)
41
+
42
+ metersPerPixel(16, 51) // ground metres per screen pixel at zoom/lat
43
+
44
+ // Patch a custom OpenFreeMap style JSON at runtime
45
+ buildOpenFreeMapPositronStyle(upstreamStyle)
46
+ patchOpenFreeMapStyle(upstreamStyle) // filters only
47
+ ```
48
+
49
+ `maplibre-gl` is a dependency (`StyleSpecification` types). `OPENFREEMAP_POSITRON_IMAGERY_USED` is the iD-style `imagery_used` label when no ELI overlay is active.
@@ -0,0 +1,5 @@
1
+ import type { StyleSpecification } from 'maplibre-gl';
2
+ /** Empty GeoJSON source + invisible top layer for `beforeId` stacking of app overlays. */
3
+ export declare const MAP_CUSTOM_CONTENT_ANCHOR_SOURCE_ID = "map-custom-content-anchor";
4
+ export declare const MAP_CUSTOM_CONTENT_ANCHOR_LAYER_ID = "map-custom-content-anchor";
5
+ export declare function appendCustomContentAnchor(style: StyleSpecification): StyleSpecification;
@@ -0,0 +1,3 @@
1
+ export { EARTH_CIRCUMFERENCE, GERMANY_LAT, lineOffsetFromMeters, lineWidthFromMeters, metersPerPixel, pixelScaleFactorAtLat, pixelsFromMeters, PIXEL_SCALE_GERMANY, TILE_SIZE, } from './meters-to-pixels';
2
+ export { focusCaseColor, focusCaseOpacity, MAP_FOCUS_MUTED_COLOR, MAP_FOCUS_MUTED_OPACITY, } from './map-focus-paint';
3
+ export { MAP_CUSTOM_CONTENT_ANCHOR_LAYER_ID, MAP_CUSTOM_CONTENT_ANCHOR_SOURCE_ID, OPENFREEMAP_POSITRON_IMAGERY_USED, OPENFREEMAP_POSITRON_STYLE, OPENFREEMAP_POSITRON_STYLE_URL, appendCustomContentAnchor, buildOpenFreeMapPositronStyle, patchOpenFreeMapStyle, } from './openfreemap-style';