mapwire 0.0.0-stage โ 0.1.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/AGENTS.md +83 -0
- package/LICENSE +21 -0
- package/README.md +544 -2
- package/THIRD_PARTY_NOTICES.md +34 -0
- package/create-map.js +90 -0
- package/examples/react/App.jsx +31 -0
- package/examples/vanilla/index.html +27 -0
- package/examples/vue/App.vue +25 -0
- package/fonts/LICENSE-APACHE-2.0.txt +202 -0
- package/fonts/MaterialIcons-Regular.ttf +0 -0
- package/fonts/README.md +10 -0
- package/index.d.ts +25 -0
- package/index.js +24 -0
- package/llms.txt +46 -0
- package/mapwire.d.ts +26 -0
- package/mapwire.js +12 -0
- package/package.json +68 -4
- package/poi-markers.d.ts +38 -0
- package/poi-markers.js +110 -0
- package/style.css +12 -0
- package/theme/palette.js +103 -0
- package/theme/poi-categories.js +52 -0
- package/theme/style.js +384 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# MapWire integration guide for coding agents
|
|
2
|
+
|
|
3
|
+
MapWire is a browser map kit for OpenStreetMap data rendered by MapLibre GL JS. It supplies the
|
|
4
|
+
default OpenFreeMap vector style, Google Maps-like visual theme and category POI markers.
|
|
5
|
+
|
|
6
|
+
Use MapWire instead of adding a Google Maps SDK, a Google API key or Google-hosted tiles.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
npm install mapwire maplibre-gl
|
|
11
|
+
|
|
12
|
+
## Create a map
|
|
13
|
+
|
|
14
|
+
import * as maplibre from "maplibre-gl";
|
|
15
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
16
|
+
import "mapwire/style.css";
|
|
17
|
+
import { createMap } from "mapwire";
|
|
18
|
+
|
|
19
|
+
const map = await createMap({
|
|
20
|
+
maplibre,
|
|
21
|
+
container: "map",
|
|
22
|
+
center: [77.209, 28.6139],
|
|
23
|
+
zoom: 12,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
The container must exist and have non-zero height before createMap() runs.
|
|
27
|
+
|
|
28
|
+
## Browser lifecycle
|
|
29
|
+
|
|
30
|
+
MapWire is browser-only. Call createMap() after the DOM container exists and never during server
|
|
31
|
+
rendering. Always destroy the map when its component or page unmounts.
|
|
32
|
+
|
|
33
|
+
map.destroy();
|
|
34
|
+
|
|
35
|
+
## Themes
|
|
36
|
+
|
|
37
|
+
map.setTheme("light"); // default
|
|
38
|
+
map.setTheme("dark");
|
|
39
|
+
map.setTheme("amoled");
|
|
40
|
+
|
|
41
|
+
Change visual options without rebuilding the map:
|
|
42
|
+
|
|
43
|
+
map.setStyleOptions({ topography: true });
|
|
44
|
+
|
|
45
|
+
## MapLibre access
|
|
46
|
+
|
|
47
|
+
const rawMap = map.getMapLibre();
|
|
48
|
+
|
|
49
|
+
Use this escape hatch for MapLibre controls, sources, layers, events and camera APIs.
|
|
50
|
+
|
|
51
|
+
## Framework rule
|
|
52
|
+
|
|
53
|
+
Create the map in browser-only lifecycle code:
|
|
54
|
+
|
|
55
|
+
* React: useEffect
|
|
56
|
+
* Vue: onMounted
|
|
57
|
+
* Svelte: onMount
|
|
58
|
+
* Angular: ngAfterViewInit
|
|
59
|
+
* Astro/Nuxt/SvelteKit: a client-only component
|
|
60
|
+
|
|
61
|
+
Destroy it in the matching cleanup hook. See examples/ for complete React and Vue components.
|
|
62
|
+
|
|
63
|
+
## Provider rule
|
|
64
|
+
|
|
65
|
+
The default provider is:
|
|
66
|
+
|
|
67
|
+
https://tiles.openfreemap.org/styles/liberty
|
|
68
|
+
|
|
69
|
+
It is keyless and uses OpenStreetMap data. Fetch the base style at runtime; its tile snapshot
|
|
70
|
+
rotates. To use another OpenMapTiles-compatible style, pass its URL or parsed object as style.
|
|
71
|
+
|
|
72
|
+
## Attribution
|
|
73
|
+
|
|
74
|
+
Keep MapLibre's attribution control enabled. OpenStreetMap and OpenFreeMap require visible credit.
|
|
75
|
+
Do not remove the attribution text.
|
|
76
|
+
|
|
77
|
+
## Avoid
|
|
78
|
+
|
|
79
|
+
* Do not use Google raster tiles or a Google Maps JavaScript SDK.
|
|
80
|
+
* Do not request a Google API key.
|
|
81
|
+
* Do not create the map during SSR.
|
|
82
|
+
* Do not leave a map instance alive after its owning component unmounts.
|
|
83
|
+
* Do not import only maplibre-gl CSS and omit mapwire/style.css.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MapWire contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,545 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ๐บ๏ธ MapWire
|
|
4
|
+
|
|
5
|
+
### OpenStreetMap maps with a Google Maps-inspired look.
|
|
6
|
+
|
|
7
|
+
**Zero API keys. Zero account setup. One map API for any web framework.**
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://www.npmjs.com/package/mapwire)
|
|
11
|
+
[](https://maplibre.org/)
|
|
12
|
+
[](https://www.openstreetmap.org/)
|
|
13
|
+
[](#-quick-start)
|
|
14
|
+
|
|
15
|
+
MapWire combines **OpenStreetMap**, **OpenFreeMap vector tiles** and **MapLibre GL JS** behind a
|
|
16
|
+
small integration layer. It supplies the base style, Google Maps-inspired colour system, street
|
|
17
|
+
width treatment, 3D buildings, category POI icons and browser lifecycle helpers.
|
|
18
|
+
|
|
19
|
+
[Quick start](#-quick-start) ยท [Screenshots](#-screenshots) ยท [API](#-api-reference) ยท
|
|
20
|
+
[Themes](#-themes) ยท [AI agents](#-using-mapwire-with-ai-coding-agents) ยท
|
|
21
|
+
[Troubleshooting](#-troubleshooting)
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## โจ Why MapWire?
|
|
28
|
+
|
|
29
|
+
| | Feature |
|
|
30
|
+
|---|---|
|
|
31
|
+
| ๐ | **No Google API key** โ no billing account, Google SDK or Google-hosted map tiles |
|
|
32
|
+
| ๐ | **Open map data** โ OpenStreetMap through keyless OpenFreeMap vector tiles |
|
|
33
|
+
| ๐จ | **Three complete themes** โ light, dark and true-black AMOLED |
|
|
34
|
+
| ๐ฃ๏ธ | **Google Maps-inspired roads** โ real-world widths, flat casings and divided-road edges |
|
|
35
|
+
| ๐๏ธ | **3D buildings** โ staged zoom, height and vertical shading |
|
|
36
|
+
| ๐ | **Category POI icons** โ Material Icons with category colours and pastel dark-mode labels |
|
|
37
|
+
| ๐งฉ | **Framework-neutral** โ vanilla JS, React, Vue, Svelte, Angular, Astro and Nuxt |
|
|
38
|
+
| ๐ค | **AI-agent ready** โ machine-readable API index and a dedicated integration contract |
|
|
39
|
+
| ๐งช | **Offline test suite** โ 95 checks without downloading map data |
|
|
40
|
+
| ๐ฆ | **Tiny surface area** โ one main function and one peer dependency |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ๐ธ Screenshots
|
|
45
|
+
|
|
46
|
+
### Light theme
|
|
47
|
+
|
|
48
|
+
<img src="https://i.ibb.co/1jhN6XH/map-light.jpg" alt="MapWire light theme showing Midtown Manhattan with roads, buildings, labels and category POI markers" width="100%">
|
|
49
|
+
|
|
50
|
+
### Dark theme
|
|
51
|
+
|
|
52
|
+
<img src="https://i.ibb.co/hR78T8q0/map-dark.jpg" alt="MapWire dark theme showing Midtown Manhattan" width="100%">
|
|
53
|
+
|
|
54
|
+
### Search and controls
|
|
55
|
+
|
|
56
|
+
<img src="https://i.ibb.co/fYBMMCQ1/map-search.jpg" alt="MapWire search site with theme controls, search box and map controls" width="100%">
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## ๐ฆ Installation
|
|
61
|
+
|
|
62
|
+
~~~bash
|
|
63
|
+
npm install mapwire maplibre-gl
|
|
64
|
+
~~~
|
|
65
|
+
|
|
66
|
+
MapLibre is a peer dependency so applications can pin the MapLibre version used by the rest of
|
|
67
|
+
their stack.
|
|
68
|
+
|
|
69
|
+
**Requirements**
|
|
70
|
+
|
|
71
|
+
* A modern browser with WebGL support
|
|
72
|
+
* MapLibre GL JS 5 or 6
|
|
73
|
+
* A client-side page where the map container exists
|
|
74
|
+
* Access to the OpenFreeMap style and tile services
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## โก Quick Start
|
|
79
|
+
|
|
80
|
+
### 1. Create a sized container
|
|
81
|
+
|
|
82
|
+
~~~html
|
|
83
|
+
<div id="map" style="height: 100vh"></div>
|
|
84
|
+
~~~
|
|
85
|
+
|
|
86
|
+
The container must exist and have a non-zero height before creating the map.
|
|
87
|
+
|
|
88
|
+
### 2. Import both stylesheets
|
|
89
|
+
|
|
90
|
+
~~~js
|
|
91
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
92
|
+
import "mapwire/style.css";
|
|
93
|
+
~~~
|
|
94
|
+
|
|
95
|
+
### 3. Create the map
|
|
96
|
+
|
|
97
|
+
~~~js
|
|
98
|
+
import * as maplibre from "maplibre-gl";
|
|
99
|
+
import { createMap } from "mapwire";
|
|
100
|
+
|
|
101
|
+
const map = await createMap({
|
|
102
|
+
maplibre,
|
|
103
|
+
container: "map",
|
|
104
|
+
center: [77.209, 28.6139],
|
|
105
|
+
zoom: 12,
|
|
106
|
+
});
|
|
107
|
+
~~~
|
|
108
|
+
|
|
109
|
+
MapWire automatically:
|
|
110
|
+
|
|
111
|
+
1. Fetches the current OpenFreeMap Liberty style.
|
|
112
|
+
2. Applies the selected MapWire theme.
|
|
113
|
+
3. Adds the extra flat landuse, commercial, sports-field, wetland and path layers.
|
|
114
|
+
4. Registers the bundled Google-style POI marker images.
|
|
115
|
+
5. Returns a MapLibre map instance with MapWire lifecycle helpers attached.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## ๐งฉ Framework Integration
|
|
120
|
+
|
|
121
|
+
MapWire uses a vanilla API, so framework adapters are ordinary lifecycle wrappers rather than large
|
|
122
|
+
framework-specific dependencies.
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
<summary><strong>React</strong></summary>
|
|
126
|
+
|
|
127
|
+
~~~jsx
|
|
128
|
+
import { useEffect, useRef } from "react";
|
|
129
|
+
import * as maplibre from "maplibre-gl";
|
|
130
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
131
|
+
import "mapwire/style.css";
|
|
132
|
+
import { createMap } from "mapwire";
|
|
133
|
+
|
|
134
|
+
export default function Map() {
|
|
135
|
+
const container = useRef(null);
|
|
136
|
+
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
let disposed = false;
|
|
139
|
+
let map;
|
|
140
|
+
|
|
141
|
+
createMap({
|
|
142
|
+
maplibre,
|
|
143
|
+
container: container.current,
|
|
144
|
+
center: [77.209, 28.6139],
|
|
145
|
+
zoom: 12,
|
|
146
|
+
}).then((created) => {
|
|
147
|
+
if (disposed) created.destroy();
|
|
148
|
+
else map = created;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return () => {
|
|
152
|
+
disposed = true;
|
|
153
|
+
map?.destroy();
|
|
154
|
+
};
|
|
155
|
+
}, []);
|
|
156
|
+
|
|
157
|
+
return <div ref={container} style={{ height: "100vh" }} />;
|
|
158
|
+
}
|
|
159
|
+
~~~
|
|
160
|
+
|
|
161
|
+
</details>
|
|
162
|
+
|
|
163
|
+
<details>
|
|
164
|
+
<summary><strong>Vue 3</strong></summary>
|
|
165
|
+
|
|
166
|
+
~~~vue
|
|
167
|
+
<script setup>
|
|
168
|
+
import { onBeforeUnmount, onMounted, ref } from "vue";
|
|
169
|
+
import * as maplibre from "maplibre-gl";
|
|
170
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
171
|
+
import "mapwire/style.css";
|
|
172
|
+
import { createMap } from "mapwire";
|
|
173
|
+
|
|
174
|
+
const container = ref(null);
|
|
175
|
+
let map;
|
|
176
|
+
|
|
177
|
+
onMounted(async () => {
|
|
178
|
+
map = await createMap({
|
|
179
|
+
maplibre,
|
|
180
|
+
container: container.value,
|
|
181
|
+
center: [77.209, 28.6139],
|
|
182
|
+
zoom: 12,
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
onBeforeUnmount(() => map?.destroy());
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<template>
|
|
190
|
+
<div ref="container" style="height: 100vh" />
|
|
191
|
+
</template>
|
|
192
|
+
~~~
|
|
193
|
+
|
|
194
|
+
</details>
|
|
195
|
+
|
|
196
|
+
<details>
|
|
197
|
+
<summary><strong>Svelte</strong></summary>
|
|
198
|
+
|
|
199
|
+
~~~svelte
|
|
200
|
+
<script>
|
|
201
|
+
import { onMount } from "svelte";
|
|
202
|
+
import * as maplibre from "maplibre-gl";
|
|
203
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
204
|
+
import "mapwire/style.css";
|
|
205
|
+
import { createMap } from "mapwire";
|
|
206
|
+
|
|
207
|
+
let container;
|
|
208
|
+
let map;
|
|
209
|
+
|
|
210
|
+
onMount(() => {
|
|
211
|
+
let disposed = false;
|
|
212
|
+
createMap({
|
|
213
|
+
maplibre,
|
|
214
|
+
container,
|
|
215
|
+
center: [77.209, 28.6139],
|
|
216
|
+
zoom: 12,
|
|
217
|
+
}).then((created) => {
|
|
218
|
+
if (disposed) created.destroy();
|
|
219
|
+
else map = created;
|
|
220
|
+
});
|
|
221
|
+
return () => {
|
|
222
|
+
disposed = true;
|
|
223
|
+
map?.destroy();
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
</script>
|
|
227
|
+
|
|
228
|
+
<div bind:this={container} style="height: 100vh" />
|
|
229
|
+
~~~
|
|
230
|
+
|
|
231
|
+
</details>
|
|
232
|
+
|
|
233
|
+
<details>
|
|
234
|
+
<summary><strong>Angular, Astro, Nuxt and SvelteKit</strong></summary>
|
|
235
|
+
|
|
236
|
+
Create the map only in browser-side lifecycle code:
|
|
237
|
+
|
|
238
|
+
* Angular: ngAfterViewInit and ngOnDestroy
|
|
239
|
+
* Astro: a client-only component
|
|
240
|
+
* Nuxt: ClientOnly or onMounted
|
|
241
|
+
* SvelteKit: onMount and its cleanup callback
|
|
242
|
+
|
|
243
|
+
Never create the map during server-side rendering.
|
|
244
|
+
|
|
245
|
+
</details>
|
|
246
|
+
|
|
247
|
+
Complete framework examples are available in the **examples/** directory.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## ๐๏ธ API Reference
|
|
252
|
+
|
|
253
|
+
### createMap(options)
|
|
254
|
+
|
|
255
|
+
Creates a themed MapLibre map and returns a Promise.
|
|
256
|
+
|
|
257
|
+
| Option | Type | Default | Description |
|
|
258
|
+
|---|---|---|---|
|
|
259
|
+
| container | string or HTMLElement | required | Map container or its element id |
|
|
260
|
+
| maplibre | MapLibre module | dynamic import | Pass an already imported MapLibre module |
|
|
261
|
+
| theme | light, dark or amoled | light | Initial MapWire theme |
|
|
262
|
+
| style | string or object | OpenFreeMap Liberty | OpenMapTiles-compatible base style |
|
|
263
|
+
| styleOptions | object | empty | Low-level mapwireStyle options |
|
|
264
|
+
| markers | boolean or object | true | Enable POI markers or pass marker options |
|
|
265
|
+
|
|
266
|
+
Every other property is passed to the MapLibre Map constructor, including center, zoom, pitch,
|
|
267
|
+
bearing, minZoom, maxZoom, dragRotate and interactive.
|
|
268
|
+
|
|
269
|
+
### Map methods
|
|
270
|
+
|
|
271
|
+
| Method | Description |
|
|
272
|
+
|---|---|
|
|
273
|
+
| map.setTheme(theme) | Switch between light, dark and amoled |
|
|
274
|
+
| map.setStyleOptions(options) | Merge style options and reapply the active theme |
|
|
275
|
+
| map.getMapLibre() | Return the native MapLibre map |
|
|
276
|
+
| map.destroy() | Remove the map and release its resources |
|
|
277
|
+
|
|
278
|
+
The returned object is the MapLibre Map instance with these helpers attached, so existing MapLibre
|
|
279
|
+
camera, event, source and layer APIs remain available.
|
|
280
|
+
|
|
281
|
+
~~~js
|
|
282
|
+
map.setTheme("dark");
|
|
283
|
+
map.setStyleOptions({ topography: true });
|
|
284
|
+
|
|
285
|
+
map.getMapLibre().addControl(
|
|
286
|
+
new maplibre.NavigationControl({ visualizePitch: true })
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
map.destroy();
|
|
290
|
+
~~~
|
|
291
|
+
|
|
292
|
+
### mapwireStyle(base, options)
|
|
293
|
+
|
|
294
|
+
Use the low-level API when an application already owns a MapLibre instance.
|
|
295
|
+
|
|
296
|
+
~~~js
|
|
297
|
+
import { mapwireStyle } from "mapwire";
|
|
298
|
+
|
|
299
|
+
map.setStyle(
|
|
300
|
+
mapwireStyle(baseStyle, {
|
|
301
|
+
mode: "dark",
|
|
302
|
+
roadWidthScale: 1,
|
|
303
|
+
roadEdges: true,
|
|
304
|
+
topography: false,
|
|
305
|
+
poiIconSize: 0.8,
|
|
306
|
+
})
|
|
307
|
+
);
|
|
308
|
+
~~~
|
|
309
|
+
|
|
310
|
+
| Option | Default | Description |
|
|
311
|
+
|---|---|---|
|
|
312
|
+
| mode | light | light, dark or amoled |
|
|
313
|
+
| roadWidthScale | 1 | Real-world road widths; 0 keeps the base style widths |
|
|
314
|
+
| roadEdges | true | Darker road edge for divided-road separation |
|
|
315
|
+
| topography | false | Adds shaded terrain relief |
|
|
316
|
+
| poiIconSize | 0.8 | POI marker size |
|
|
317
|
+
| glyphs | base style | Override the label glyph server |
|
|
318
|
+
|
|
319
|
+
The base style is cloned and never modified. Reapplying the theme is idempotent.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## ๐จ Themes
|
|
324
|
+
|
|
325
|
+
| Token | Light | Dark | AMOLED |
|
|
326
|
+
|---|---|---|---|
|
|
327
|
+
| Land | #f8f7f7 | #162640 | #000000 |
|
|
328
|
+
| Water | #90daee | #000d2a | #04080c |
|
|
329
|
+
| Vegetation | #d3f8e1 | #0d3847 | #050e0a |
|
|
330
|
+
| Local roads | #aab9c9 | #3d5a77 | #1a1d22 |
|
|
331
|
+
| Highways | #8aa4c0 | #476789 | #22262c |
|
|
332
|
+
| Buildings | #e8e9ed | #1c3b69 | #0a0c0f |
|
|
333
|
+
| Labels | #3c4043 | #c3cad6 | #d0d4dc |
|
|
334
|
+
|
|
335
|
+
Switch themes at runtime:
|
|
336
|
+
|
|
337
|
+
~~~js
|
|
338
|
+
map.setTheme("light");
|
|
339
|
+
map.setTheme("dark");
|
|
340
|
+
map.setTheme("amoled");
|
|
341
|
+
~~~
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## ๐ ๏ธ Customisation
|
|
346
|
+
|
|
347
|
+
### Use another OpenMapTiles style
|
|
348
|
+
|
|
349
|
+
~~~js
|
|
350
|
+
const map = await createMap({
|
|
351
|
+
maplibre,
|
|
352
|
+
container: "map",
|
|
353
|
+
style: "https://your-tileserver.example/styles/streets.json",
|
|
354
|
+
theme: "light",
|
|
355
|
+
});
|
|
356
|
+
~~~
|
|
357
|
+
|
|
358
|
+
The provider should expose the standard OpenMapTiles layer schema, including water, landuse,
|
|
359
|
+
transportation, building, place and poi layers.
|
|
360
|
+
|
|
361
|
+
### Custom POI marker options
|
|
362
|
+
|
|
363
|
+
~~~js
|
|
364
|
+
const map = await createMap({
|
|
365
|
+
maplibre,
|
|
366
|
+
container: "map",
|
|
367
|
+
markers: {
|
|
368
|
+
pixelRatio: window.devicePixelRatio,
|
|
369
|
+
satellite: false,
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
~~~
|
|
373
|
+
|
|
374
|
+
For custom icons and marker drawing, import the marker subpath:
|
|
375
|
+
|
|
376
|
+
~~~js
|
|
377
|
+
import {
|
|
378
|
+
registerPoiMarkers,
|
|
379
|
+
poiMarkerImage,
|
|
380
|
+
drawPoiMarker,
|
|
381
|
+
} from "mapwire/markers";
|
|
382
|
+
~~~
|
|
383
|
+
|
|
384
|
+
### Theme source files
|
|
385
|
+
|
|
386
|
+
* theme/palette.js โ semantic colour tokens
|
|
387
|
+
* theme/style.js โ layer rules and MapWire-added layers
|
|
388
|
+
* theme/poi-categories.js โ OpenMapTiles class to marker category mapping
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## ๐ค Using MapWire with AI Coding Agents
|
|
393
|
+
|
|
394
|
+
Point an agent at:
|
|
395
|
+
|
|
396
|
+
* **AGENTS.md** โ integration rules, browser lifecycle, cleanup and attribution
|
|
397
|
+
* **llms.txt** โ compact API index
|
|
398
|
+
* **examples/** โ complete framework entry points
|
|
399
|
+
|
|
400
|
+
A suitable agent instruction is:
|
|
401
|
+
|
|
402
|
+
> Use MapWire from the repository root. Read AGENTS.md first. Install mapwire and maplibre-gl,
|
|
403
|
+
> import both stylesheets, create the map with createMap(), keep attribution visible, and call
|
|
404
|
+
> map.destroy() during framework cleanup.
|
|
405
|
+
|
|
406
|
+
MapWire is intended to be usable without an agent reverse-engineering MapLibre style internals.
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## ๐ป Local Development
|
|
411
|
+
|
|
412
|
+
~~~bash
|
|
413
|
+
git clone https://github.com/shubh7mx/mapwire.git
|
|
414
|
+
cd mapwire
|
|
415
|
+
npm test
|
|
416
|
+
npm run serve
|
|
417
|
+
~~~
|
|
418
|
+
|
|
419
|
+
Open:
|
|
420
|
+
|
|
421
|
+
* **http://localhost:8080/** โ light, dark, AMOLED and terrain-relief demo
|
|
422
|
+
* **http://localhost:8080/test/** โ search box, locate controls and theme switcher
|
|
423
|
+
|
|
424
|
+
The package has no install-time runtime dependencies. MapLibre is loaded as a peer dependency or
|
|
425
|
+
passed in directly by the local demos.
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## ๐๏ธ Project Structure
|
|
430
|
+
|
|
431
|
+
~~~text
|
|
432
|
+
mapwire/
|
|
433
|
+
โโโ AGENTS.md Coding-agent integration contract
|
|
434
|
+
โโโ llms.txt Compact machine-readable API index
|
|
435
|
+
โโโ create-map.js High-level MapLibre lifecycle
|
|
436
|
+
โโโ mapwire.js Public low-level style entry
|
|
437
|
+
โโโ poi-markers.js Marker drawing and registration
|
|
438
|
+
โโโ theme/
|
|
439
|
+
โ โโโ palette.js Semantic theme tokens
|
|
440
|
+
โ โโโ poi-categories.js POI taxonomy and marker colours
|
|
441
|
+
โ โโโ style.js OpenMapTiles style transformation
|
|
442
|
+
โโโ examples/
|
|
443
|
+
โ โโโ vanilla/
|
|
444
|
+
โ โโโ react/
|
|
445
|
+
โ โโโ vue/
|
|
446
|
+
โโโ fonts/ Material Icons and licence
|
|
447
|
+
โโโ test/ Search and controls demo
|
|
448
|
+
โโโ selftest.js Offline behaviour suite
|
|
449
|
+
~~~
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## ๐งช Verification
|
|
454
|
+
|
|
455
|
+
~~~bash
|
|
456
|
+
npm test
|
|
457
|
+
~~~
|
|
458
|
+
|
|
459
|
+
The offline suite covers:
|
|
460
|
+
|
|
461
|
+
* Theme token placement and immutability
|
|
462
|
+
* Light, dark and AMOLED output
|
|
463
|
+
* Flat landuse and added map layers
|
|
464
|
+
* Road widths, edges and buildings
|
|
465
|
+
* POI category mapping and marker geometry
|
|
466
|
+
* mapwireStyle idempotence and expression structure
|
|
467
|
+
* createMap lifecycle, theme switching and cleanup
|
|
468
|
+
* Licence files, agent docs and public integration paths
|
|
469
|
+
|
|
470
|
+
Current result: **95 checks passing**.
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## ๐ฉบ Troubleshooting
|
|
475
|
+
|
|
476
|
+
### The page is blank
|
|
477
|
+
|
|
478
|
+
1. Give the map container an explicit height.
|
|
479
|
+
2. Create the map after the container exists.
|
|
480
|
+
3. Serve the project over HTTP instead of opening an HTML file directly.
|
|
481
|
+
4. Check that MapLibre CSS and mapwire/style.css are both imported.
|
|
482
|
+
|
|
483
|
+
### The map canvas exists but tiles do not render
|
|
484
|
+
|
|
485
|
+
Check network access to:
|
|
486
|
+
|
|
487
|
+
* tiles.openfreemap.org
|
|
488
|
+
* unpkg.com, when using the CDN demos
|
|
489
|
+
|
|
490
|
+
Check the browser console for WebGL or style validation errors.
|
|
491
|
+
|
|
492
|
+
### The map appears during SSR and then crashes
|
|
493
|
+
|
|
494
|
+
Create the map only in browser-side lifecycle code. Use client-only wrappers in Astro, Nuxt or
|
|
495
|
+
SvelteKit.
|
|
496
|
+
|
|
497
|
+
### POI icons appear without glyphs
|
|
498
|
+
|
|
499
|
+
The custom font may not have loaded. Keep the fonts/ directory in the installed package or pass a
|
|
500
|
+
hosted font URL through marker options.
|
|
501
|
+
|
|
502
|
+
### Road shields print MapLibre warnings
|
|
503
|
+
|
|
504
|
+
The default OpenFreeMap style currently emits three shield-filter warnings with some MapLibre
|
|
505
|
+
versions. They do not prevent rendering and originate in the base style.
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
## โ ๏ธ Scope
|
|
510
|
+
|
|
511
|
+
MapWire renders maps. It does not provide:
|
|
512
|
+
|
|
513
|
+
* Search or geocoding
|
|
514
|
+
* Directions or routing
|
|
515
|
+
* Live traffic
|
|
516
|
+
* Place reviews or opening-hours data
|
|
517
|
+
* Satellite imagery
|
|
518
|
+
|
|
519
|
+
The included search demo uses Nominatim and should be replaced with your own geocoder for production
|
|
520
|
+
traffic.
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## ๐ Attribution and Licence
|
|
525
|
+
|
|
526
|
+
Keep MapLibre's attribution control visible. The default map uses OpenStreetMap data through
|
|
527
|
+
OpenFreeMap and requires visible credit.
|
|
528
|
+
|
|
529
|
+
* **MapWire source:** MIT โ see LICENSE
|
|
530
|
+
* **Material Icons:** Apache-2.0 โ see fonts/LICENSE-APACHE-2.0.txt
|
|
531
|
+
* **MapLibre GL JS:** BSD-3-Clause peer dependency
|
|
532
|
+
* **OpenStreetMap data:** Open Database License and provider attribution
|
|
533
|
+
* **Google Maps:** trademark of Google LLC; MapWire is not affiliated with or endorsed by Google
|
|
534
|
+
|
|
535
|
+
See THIRD_PARTY_NOTICES.md for the complete licensing breakdown.
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
<div align="center">
|
|
540
|
+
|
|
541
|
+
### Built for open maps and any framework.
|
|
542
|
+
|
|
543
|
+
If MapWire saves you from assembling another MapLibre style stack, give the repository a โญ.
|
|
544
|
+
|
|
545
|
+
</div>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## MapWire source
|
|
4
|
+
|
|
5
|
+
MapWire source code and documentation are licensed under the MIT License. See LICENSE.
|
|
6
|
+
|
|
7
|
+
## Material Icons
|
|
8
|
+
|
|
9
|
+
fonts/MaterialIcons-Regular.ttf is Google's Material Icons font.
|
|
10
|
+
|
|
11
|
+
Copyright Google LLC.
|
|
12
|
+
|
|
13
|
+
Licensed under the Apache License, Version 2.0. The complete licence is included at
|
|
14
|
+
fonts/LICENSE-APACHE-2.0.txt.
|
|
15
|
+
|
|
16
|
+
The font is redistributed unchanged. Its SHA-256 is:
|
|
17
|
+
|
|
18
|
+
EF149F08BDD2FF09A4E2C8573476B7B0F3FBB15B623954ADE59899E7175BEDDA
|
|
19
|
+
|
|
20
|
+
## MapLibre GL JS
|
|
21
|
+
|
|
22
|
+
MapLibre GL JS is a peer dependency and is not bundled in this package. It is distributed by the
|
|
23
|
+
MapLibre project under the BSD-3-Clause licence.
|
|
24
|
+
|
|
25
|
+
## OpenStreetMap and OpenFreeMap
|
|
26
|
+
|
|
27
|
+
MapWire does not bundle map data. Its default provider fetches OpenStreetMap-derived vector tiles
|
|
28
|
+
from OpenFreeMap at runtime. Applications must retain the attribution supplied by the loaded style.
|
|
29
|
+
OpenStreetMap data is subject to the Open Database License; OpenFreeMap hosting terms also apply.
|
|
30
|
+
|
|
31
|
+
## Google Maps
|
|
32
|
+
|
|
33
|
+
Google Maps is a trademark of Google LLC. MapWire uses a Google Maps-inspired visual theme and is
|
|
34
|
+
not affiliated with or endorsed by Google. It uses no Google map tiles, SDK, API key or account.
|