@maplibre-yaml/core 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.
@@ -0,0 +1,149 @@
1
+ import maplibregl, { Map } from 'maplibre-gl';
2
+ import { z } from 'zod';
3
+ import { L as LayerSchema, a as LegendConfigSchema, M as MapConfigSchema, C as ControlsConfigSchema } from './map.schema-EnZRrtIh.js';
4
+
5
+ /**
6
+ * @file Legend builder for map layers
7
+ * @module @maplibre-yaml/core/renderer
8
+ */
9
+
10
+ type Layer$1 = z.infer<typeof LayerSchema>;
11
+ type LegendConfig$1 = z.infer<typeof LegendConfigSchema>;
12
+ /**
13
+ * Builds legend HTML from layer configurations
14
+ */
15
+ declare class LegendBuilder {
16
+ /**
17
+ * Build legend in container from layers
18
+ */
19
+ build(container: string | HTMLElement, layers: Layer$1[], config?: Partial<LegendConfig$1>): void;
20
+ /**
21
+ * Render a single legend item
22
+ */
23
+ private renderItem;
24
+ /**
25
+ * Extract legend items from layers
26
+ */
27
+ private extractItems;
28
+ /**
29
+ * Escape HTML to prevent XSS
30
+ */
31
+ private escapeHtml;
32
+ }
33
+
34
+ /**
35
+ * @file Main map renderer for MapLibre YAML
36
+ * @module @maplibre-yaml/core/renderer
37
+ */
38
+
39
+ type MapConfig = z.infer<typeof MapConfigSchema>;
40
+ type Layer = z.infer<typeof LayerSchema>;
41
+ type ControlsConfig = z.infer<typeof ControlsConfigSchema>;
42
+ type LegendConfig = z.infer<typeof LegendConfigSchema>;
43
+ /**
44
+ * Options for MapRenderer
45
+ */
46
+ interface MapRendererOptions {
47
+ onLoad?: () => void;
48
+ onError?: (error: Error) => void;
49
+ }
50
+ /**
51
+ * Events emitted by MapRenderer
52
+ */
53
+ interface MapRendererEvents {
54
+ load: void;
55
+ 'layer:added': {
56
+ layerId: string;
57
+ };
58
+ 'layer:removed': {
59
+ layerId: string;
60
+ };
61
+ 'layer:data-loading': {
62
+ layerId: string;
63
+ };
64
+ 'layer:data-loaded': {
65
+ layerId: string;
66
+ featureCount: number;
67
+ };
68
+ 'layer:data-error': {
69
+ layerId: string;
70
+ error: Error;
71
+ };
72
+ 'layer:click': {
73
+ layerId: string;
74
+ feature: any;
75
+ lngLat: maplibregl.LngLat;
76
+ };
77
+ 'layer:hover': {
78
+ layerId: string;
79
+ feature: any;
80
+ lngLat: maplibregl.LngLat;
81
+ };
82
+ }
83
+ /**
84
+ * Main class for rendering maps from configuration
85
+ */
86
+ declare class MapRenderer {
87
+ private map;
88
+ private layerManager;
89
+ private eventHandler;
90
+ private legendBuilder;
91
+ private controlsManager;
92
+ private eventListeners;
93
+ private isLoaded;
94
+ constructor(container: string | HTMLElement, config: MapConfig, layers?: Layer[], options?: MapRendererOptions);
95
+ /**
96
+ * Get the underlying MapLibre map instance
97
+ */
98
+ getMap(): Map;
99
+ /**
100
+ * Check if map is loaded
101
+ */
102
+ isMapLoaded(): boolean;
103
+ /**
104
+ * Add a layer to the map
105
+ */
106
+ addLayer(layer: Layer): Promise<void>;
107
+ /**
108
+ * Remove a layer from the map
109
+ */
110
+ removeLayer(layerId: string): void;
111
+ /**
112
+ * Set layer visibility
113
+ */
114
+ setLayerVisibility(layerId: string, visible: boolean): void;
115
+ /**
116
+ * Update layer data
117
+ */
118
+ updateLayerData(layerId: string, data: GeoJSON.GeoJSON): void;
119
+ /**
120
+ * Add controls to the map
121
+ */
122
+ addControls(config: ControlsConfig): void;
123
+ /**
124
+ * Build legend in container
125
+ */
126
+ buildLegend(container: string | HTMLElement, layers: Layer[], config?: LegendConfig): void;
127
+ /**
128
+ * Get the legend builder instance
129
+ */
130
+ getLegendBuilder(): LegendBuilder;
131
+ /**
132
+ * Register an event listener
133
+ */
134
+ on<K extends keyof MapRendererEvents>(event: K, callback: (data: MapRendererEvents[K]) => void): void;
135
+ /**
136
+ * Unregister an event listener
137
+ */
138
+ off<K extends keyof MapRendererEvents>(event: K, callback: Function): void;
139
+ /**
140
+ * Emit an event
141
+ */
142
+ private emit;
143
+ /**
144
+ * Destroy the map and clean up resources
145
+ */
146
+ destroy(): void;
147
+ }
148
+
149
+ export { LegendBuilder as L, MapRenderer as M, type MapRendererOptions as a, type MapRendererEvents as b };