@maplibre-yaml/core 0.1.0-alpha.0 → 0.1.1
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 +1214 -0
- package/dist/components/index.d.ts +4 -83
- package/dist/components/index.js +4318 -3919
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +6 -315
- package/dist/index.js +115 -18
- package/dist/index.js.map +1 -1
- package/dist/map-renderer-DOLO9y-3.d.ts +522 -0
- package/dist/{map.schema-EnZRrtIh.d.ts → page.schema-CzdCyPFI.d.ts} +775 -368
- package/dist/register.browser.js +16004 -0
- package/dist/register.browser.js.map +1 -0
- package/dist/register.d.ts +205 -0
- package/dist/register.js +4704 -0
- package/dist/register.js.map +1 -0
- package/dist/schemas/index.d.ts +12 -419
- package/dist/schemas/index.js +4 -2
- package/dist/schemas/index.js.map +1 -1
- package/package.json +18 -13
- package/LICENSE.md +0 -21
- package/dist/map-renderer-RQc5_bdo.d.ts +0 -149
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Map } from 'maplibre-gl';
|
|
2
|
+
import { M as MapBlock, b as MapRenderer } from './map-renderer-DOLO9y-3.js';
|
|
3
|
+
import './page.schema-CzdCyPFI.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @file Unified MLMap web component for maplibre-yaml
|
|
8
|
+
* @module @maplibre-yaml/core/components/ml-map
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* The `<ml-map>` component is the primary way to embed MapLibre maps configured
|
|
12
|
+
* with YAML. It supports multiple configuration methods to fit any use case.
|
|
13
|
+
*
|
|
14
|
+
* ## Configuration Methods (in priority order)
|
|
15
|
+
*
|
|
16
|
+
* ### 1. External YAML File (Recommended)
|
|
17
|
+
* ```html
|
|
18
|
+
* <ml-map src="/configs/my-map.yaml"></ml-map>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ### 2. Inline YAML via Script Tag
|
|
22
|
+
* ```html
|
|
23
|
+
* <ml-map>
|
|
24
|
+
* <script type="text/yaml">
|
|
25
|
+
* type: map
|
|
26
|
+
* id: my-map
|
|
27
|
+
* config:
|
|
28
|
+
* center: [-74.006, 40.7128]
|
|
29
|
+
* zoom: 12
|
|
30
|
+
* mapStyle: "https://demotiles.maplibre.org/style.json"
|
|
31
|
+
* layers: []
|
|
32
|
+
* </script>
|
|
33
|
+
* </ml-map>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ### 3. JSON Config Attribute (Programmatic)
|
|
37
|
+
* ```html
|
|
38
|
+
* <ml-map config='{"type":"map",...}'></ml-map>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* MLMap custom element for rendering MapLibre maps from YAML/JSON configuration.
|
|
44
|
+
*
|
|
45
|
+
* @fires ml-map:load - Map loaded and ready for interaction
|
|
46
|
+
* @fires ml-map:error - Error during initialization or runtime
|
|
47
|
+
* @fires ml-map:loading - Loading configuration from URL
|
|
48
|
+
* @fires ml-map:layer-added - Layer was added to the map
|
|
49
|
+
* @fires ml-map:layer-removed - Layer was removed from the map
|
|
50
|
+
* @fires ml-map:layer-data-loading - Layer data is being fetched
|
|
51
|
+
* @fires ml-map:layer-data-loaded - Layer data loaded successfully
|
|
52
|
+
* @fires ml-map:layer-data-error - Layer data failed to load
|
|
53
|
+
* @fires ml-map:layer-click - User clicked on a layer feature
|
|
54
|
+
* @fires ml-map:layer-hover - User hovered over a layer feature
|
|
55
|
+
*/
|
|
56
|
+
declare class MLMap extends HTMLElement {
|
|
57
|
+
/** Internal MapRenderer instance */
|
|
58
|
+
private renderer;
|
|
59
|
+
/** Whether the component has been initialized */
|
|
60
|
+
private initialized;
|
|
61
|
+
/** Container element for the map */
|
|
62
|
+
private mapContainer;
|
|
63
|
+
/** Parsed and validated configuration */
|
|
64
|
+
private _config;
|
|
65
|
+
/**
|
|
66
|
+
* Observed attributes that trigger attributeChangedCallback
|
|
67
|
+
*/
|
|
68
|
+
static get observedAttributes(): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Get the current map configuration
|
|
71
|
+
*/
|
|
72
|
+
get config(): MapBlock | null;
|
|
73
|
+
/**
|
|
74
|
+
* Set the map configuration programmatically
|
|
75
|
+
*/
|
|
76
|
+
set config(value: MapBlock | string | null);
|
|
77
|
+
/**
|
|
78
|
+
* Called when the element is added to the DOM
|
|
79
|
+
*/
|
|
80
|
+
connectedCallback(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Called when the element is removed from the DOM
|
|
83
|
+
*/
|
|
84
|
+
disconnectedCallback(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Called when an observed attribute changes
|
|
87
|
+
*/
|
|
88
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
89
|
+
/**
|
|
90
|
+
* Initialize the component by detecting and loading configuration
|
|
91
|
+
*/
|
|
92
|
+
private initialize;
|
|
93
|
+
/**
|
|
94
|
+
* Load and parse YAML from a script tag's text content
|
|
95
|
+
*/
|
|
96
|
+
private loadFromScriptTag;
|
|
97
|
+
/**
|
|
98
|
+
* Load and parse YAML from an external URL
|
|
99
|
+
*/
|
|
100
|
+
private loadFromURL;
|
|
101
|
+
/**
|
|
102
|
+
* Parse and validate JSON from the config attribute
|
|
103
|
+
*/
|
|
104
|
+
private loadFromJSONAttribute;
|
|
105
|
+
/**
|
|
106
|
+
* Render the map with the given configuration
|
|
107
|
+
*/
|
|
108
|
+
private renderMap;
|
|
109
|
+
/**
|
|
110
|
+
* Forward MapRenderer events to custom element events
|
|
111
|
+
*/
|
|
112
|
+
private setupEventForwarding;
|
|
113
|
+
/**
|
|
114
|
+
* Handle and display errors
|
|
115
|
+
*/
|
|
116
|
+
private handleError;
|
|
117
|
+
/**
|
|
118
|
+
* Escape HTML special characters for safe innerHTML usage
|
|
119
|
+
*/
|
|
120
|
+
private escapeHtml;
|
|
121
|
+
/**
|
|
122
|
+
* Clean up resources when component is removed
|
|
123
|
+
*/
|
|
124
|
+
private destroy;
|
|
125
|
+
/**
|
|
126
|
+
* Get the underlying MapLibre GL map instance
|
|
127
|
+
*
|
|
128
|
+
* @returns The MapLibre GL map instance, or null if not initialized
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```javascript
|
|
132
|
+
* const mapEl = document.querySelector('ml-map');
|
|
133
|
+
*
|
|
134
|
+
* mapEl.addEventListener('ml-map:load', () => {
|
|
135
|
+
* const map = mapEl.getMap();
|
|
136
|
+
* map.flyTo({ center: [-122.4, 37.8], zoom: 14 });
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
getMap(): Map | null;
|
|
141
|
+
/**
|
|
142
|
+
* Get the MapRenderer instance
|
|
143
|
+
*
|
|
144
|
+
* @returns The MapRenderer instance, or null if not initialized
|
|
145
|
+
*/
|
|
146
|
+
getRenderer(): MapRenderer | null;
|
|
147
|
+
/**
|
|
148
|
+
* Check if the map is loaded
|
|
149
|
+
*
|
|
150
|
+
* @returns True if the map has finished loading
|
|
151
|
+
*/
|
|
152
|
+
isLoaded(): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Add a layer to the map
|
|
155
|
+
*
|
|
156
|
+
* @param layer - Layer configuration object
|
|
157
|
+
* @returns Promise that resolves when the layer is added
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```javascript
|
|
161
|
+
* await mapEl.addLayer({
|
|
162
|
+
* id: 'new-layer',
|
|
163
|
+
* type: 'circle',
|
|
164
|
+
* source: {
|
|
165
|
+
* type: 'geojson',
|
|
166
|
+
* data: { type: 'FeatureCollection', features: [] }
|
|
167
|
+
* },
|
|
168
|
+
* paint: { 'circle-radius': 6, 'circle-color': '#ff0000' }
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
addLayer(layer: any): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Remove a layer from the map
|
|
175
|
+
*
|
|
176
|
+
* @param layerId - ID of the layer to remove
|
|
177
|
+
*/
|
|
178
|
+
removeLayer(layerId: string): void;
|
|
179
|
+
/**
|
|
180
|
+
* Set layer visibility
|
|
181
|
+
*
|
|
182
|
+
* @param layerId - ID of the layer
|
|
183
|
+
* @param visible - Whether the layer should be visible
|
|
184
|
+
*/
|
|
185
|
+
setLayerVisibility(layerId: string, visible: boolean): void;
|
|
186
|
+
/**
|
|
187
|
+
* Update layer data
|
|
188
|
+
*
|
|
189
|
+
* @param layerId - ID of the layer
|
|
190
|
+
* @param data - New GeoJSON data
|
|
191
|
+
*/
|
|
192
|
+
updateLayerData(layerId: string, data: GeoJSON.GeoJSON): void;
|
|
193
|
+
/**
|
|
194
|
+
* Reload configuration from the current source
|
|
195
|
+
*
|
|
196
|
+
* @returns Promise that resolves when reload is complete
|
|
197
|
+
*/
|
|
198
|
+
reload(): Promise<void>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Register the ml-map custom element
|
|
202
|
+
*/
|
|
203
|
+
declare function registerMLMap(): void;
|
|
204
|
+
|
|
205
|
+
export { MLMap, registerMLMap };
|