@ogis/waymark-js 2.0.0-alpha.9 β 3.0.0-alpha
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/dist/waymark-js.css +1 -14
- package/dist/waymark-js.js +11185 -15510
- package/dist/waymark-js.umd.cjs +64 -87
- package/package.json +16 -9
- package/readme.md +86 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogis/waymark-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-2.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -23,24 +23,31 @@
|
|
|
23
23
|
".": {
|
|
24
24
|
"import": "./dist/waymark-js.js",
|
|
25
25
|
"require": "./dist/waymark-js.umd.cjs"
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"./dist/waymark-js.css": "./dist/waymark-js.css"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "vite build",
|
|
30
|
-
"dev": "vite --host"
|
|
31
|
+
"dev": "concurrently \"vite --host\" \"npm run test:watch\"",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest watch"
|
|
34
|
+
},
|
|
35
|
+
"vitest": {
|
|
36
|
+
"setupFiles": "./tests/setupTests.js"
|
|
31
37
|
},
|
|
32
38
|
"dependencies": {
|
|
39
|
+
"@turf/bbox": "^7.3.2",
|
|
33
40
|
"@turf/length": "^7.2.0",
|
|
34
|
-
"
|
|
35
|
-
"ionicons-npm": "^2.0.1",
|
|
41
|
+
"lodash-es": "^4.17.22",
|
|
36
42
|
"maplibre-gl": "^5.7.1",
|
|
37
|
-
"
|
|
38
|
-
"vue": "^3.4.21"
|
|
43
|
+
"ulid": "^3.0.2"
|
|
39
44
|
},
|
|
40
45
|
"devDependencies": {
|
|
41
|
-
"
|
|
46
|
+
"concurrently": "^9.2.1",
|
|
47
|
+
"jsdom": "^24.1.0",
|
|
42
48
|
"less": "^4.2.0",
|
|
43
49
|
"prettier": "^3.2.5",
|
|
44
|
-
"vite": "^6.3.5"
|
|
50
|
+
"vite": "^6.3.5",
|
|
51
|
+
"vitest": "^4.0.17"
|
|
45
52
|
}
|
|
46
53
|
}
|
package/readme.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Waymark JS
|
|
2
2
|
|
|
3
3
|
> [!CAUTION]
|
|
4
|
-
> Waymark JS
|
|
4
|
+
> Waymark JS v3 is currently in alpha.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Adding _meaning_ to GeoJSON.
|
|
7
7
|
|
|
8
|
-
Waymark JS is a JavaScript library for
|
|
8
|
+
Waymark JS is a JavaScript library for rendering GeoJSON data on a [OpenStreetMap](https://www.openstreetmap.org/) vector basemap.
|
|
9
9
|
|
|
10
10
|
Built on the shoulders of giants:
|
|
11
11
|
|
|
@@ -26,7 +26,7 @@ npm install @ogis/waymark-js
|
|
|
26
26
|
Then import the library and CSS in your JavaScript:
|
|
27
27
|
|
|
28
28
|
```javascript
|
|
29
|
-
import {
|
|
29
|
+
import { createInstance } from "@ogis/waymark-js";
|
|
30
30
|
import "@ogis/waymark-js/dist/waymark-js.css";
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -43,10 +43,11 @@ To use via CDN, include the following in your HTML:
|
|
|
43
43
|
/>
|
|
44
44
|
|
|
45
45
|
<script type="module">
|
|
46
|
-
import {
|
|
46
|
+
import { createInstance } from "https://unpkg.com/@ogis/waymark-js/dist/waymark-js.js";
|
|
47
47
|
</script>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
<!--
|
|
50
51
|
#### UMD
|
|
51
52
|
|
|
52
53
|
When you can't rely on native ES modules, you can load the bundled UMD build via a classic `<script>` tag. The bundle exposes a `WaymarkJS` global with the same `Instance` class that the package exports.
|
|
@@ -69,7 +70,9 @@ When you can't rely on native ES modules, you can load the bundled UMD build via
|
|
|
69
70
|
<div id="waymark-instance" style="height: 480px"></div>
|
|
70
71
|
<script>
|
|
71
72
|
window.addEventListener("DOMContentLoaded", () => {
|
|
72
|
-
const instance = new WaymarkJS.
|
|
73
|
+
const instance = new WaymarkJS.createInstance({
|
|
74
|
+
id: "waymark-instance",
|
|
75
|
+
});
|
|
73
76
|
});
|
|
74
77
|
</script>
|
|
75
78
|
</body>
|
|
@@ -77,6 +80,7 @@ When you can't rely on native ES modules, you can load the bundled UMD build via
|
|
|
77
80
|
```
|
|
78
81
|
|
|
79
82
|
If you're self-hosting the assets, replace the CDN URLs with your local `waymark-js.css` and `waymark-js.umd.cjs` paths.
|
|
83
|
+
-->
|
|
80
84
|
|
|
81
85
|
## Usage
|
|
82
86
|
|
|
@@ -89,86 +93,98 @@ Add a container element for the Instance:
|
|
|
89
93
|
```
|
|
90
94
|
|
|
91
95
|
> [!NOTE]
|
|
92
|
-
>
|
|
96
|
+
> Instance element must have a **height** in order to be visible.
|
|
97
|
+
> If there isn't a DOM element with the given id, Waymark JS will create one for you and append it to the body (with 100% width and height).
|
|
93
98
|
|
|
94
99
|
### JavaScript
|
|
95
100
|
|
|
96
|
-
Create a Waymark Instance with your configuration,
|
|
101
|
+
Create a Waymark Instance with your configuration, showing some GeoJSON data:
|
|
97
102
|
|
|
98
103
|
```javascript
|
|
99
|
-
import {
|
|
104
|
+
import { createInstance } from "@ogis/waymark-js";
|
|
100
105
|
import "@ogis/waymark-js/dist/waymark-js.css";
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
const instance = createInstance({
|
|
108
|
+
// Will console.log() all Waymark JS Events
|
|
109
|
+
// debug: true,
|
|
110
|
+
|
|
111
|
+
// Unique ID repesenting the DOM element to load the Instance into
|
|
112
|
+
// Is added to the DOM if it doesn't exist
|
|
113
|
+
id: "waymark-instance",
|
|
114
|
+
|
|
115
|
+
// MapLibre GL JS Options
|
|
116
|
+
// See [MapLibre Map Options](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/)
|
|
117
|
+
mapOptions: {
|
|
118
|
+
zoom: 12,
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
// Can pass GeoJSON here
|
|
122
|
+
geoJSON: {
|
|
123
|
+
type: "FeatureCollection",
|
|
124
|
+
features: [
|
|
117
125
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
// Set an ID here so you can access the Overlay
|
|
127
|
+
id: "pub-marker",
|
|
128
|
+
type: "Feature",
|
|
129
|
+
properties: {
|
|
130
|
+
// Waymark Properties
|
|
131
|
+
waymark: {
|
|
132
|
+
// The Title & Descrption will display when the Marker is clicked
|
|
133
|
+
title: "The Scarlet Ibis",
|
|
134
|
+
description:
|
|
135
|
+
"Great pub, great food! Especially after a Long Ride π΄πππΊπΊπ€",
|
|
136
|
+
|
|
137
|
+
// MapLibre GL JS Layer Paint Properties
|
|
138
|
+
paint: {
|
|
139
|
+
"circle-radius": 20,
|
|
140
|
+
"circle-color": "white",
|
|
141
|
+
"circle-stroke-color": "brown",
|
|
142
|
+
"circle-stroke-width": 6,
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// Marker Icons
|
|
146
|
+
icon: {
|
|
147
|
+
// <img /> and <i /> tags work well here
|
|
148
|
+
html: `<div style="font-size:32px">πΊ</div>`,
|
|
149
|
+
|
|
150
|
+
// Inline SVG supported
|
|
151
|
+
// svg: `<svg />`
|
|
152
|
+
|
|
153
|
+
// Image URLs supported
|
|
154
|
+
// url: "https://...pint.png
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
geometry: {
|
|
159
|
+
type: "Point",
|
|
160
|
+
coordinates: [-128.0094, 50.6539],
|
|
161
|
+
},
|
|
125
162
|
},
|
|
126
163
|
],
|
|
127
164
|
},
|
|
128
|
-
});
|
|
129
165
|
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
geometry: {
|
|
144
|
-
type: "Point",
|
|
145
|
-
coordinates: [-128.0094, 50.6539],
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
],
|
|
166
|
+
// This function is called when the Instance has finished loading
|
|
167
|
+
// and is passed the Instance as an argument
|
|
168
|
+
onLoad: (thisInstance) => {
|
|
169
|
+
//Get the Waymark JS Overlay for the "pub-marker" Feature
|
|
170
|
+
const pubMarker = thisInstance.geoJSONStore.getItem("pub-marker");
|
|
171
|
+
|
|
172
|
+
// Get the MapLibre GL JS Map
|
|
173
|
+
const map = thisInstance.mapLibreStore.mapLibreMap;
|
|
174
|
+
|
|
175
|
+
// Set the map view to fit the Marker (instantly)
|
|
176
|
+
map.setCenter(pubMarker.geometry.coordinates);
|
|
177
|
+
map.setZoom(12);
|
|
178
|
+
},
|
|
149
179
|
});
|
|
150
180
|
```
|
|
151
181
|
|
|
182
|
+
<!--
|
|
152
183
|
## Documentation
|
|
153
184
|
|
|
154
|
-
1. [Start Here](docs/
|
|
155
|
-
2. [Instances](docs/
|
|
156
|
-
|
|
157
|
-
## To-Do
|
|
158
|
-
|
|
159
|
-
Alpha
|
|
160
|
-
|
|
161
|
-
- [ ] Demo PAGE
|
|
162
|
-
|
|
163
|
-
Later
|
|
164
|
-
|
|
165
|
-
- [ ] Map Options:
|
|
166
|
-
- [ ] `map_init_basemap`
|
|
167
|
-
- [ ] `show_scale`
|
|
168
|
-
- [ ] `debug_mode`
|
|
169
|
-
- [ ] Viewer Options
|
|
170
|
-
- [ ] Editor Options
|
|
171
|
-
- [ ] GPX/KML Import/Export
|
|
185
|
+
1. [Start Here](docs/v3/1.index.md)
|
|
186
|
+
2. [Instances](docs/v3/2.instances.md)
|
|
187
|
+
-->
|
|
172
188
|
|
|
173
189
|
## Development
|
|
174
190
|
|
|
@@ -179,7 +195,7 @@ Later
|
|
|
179
195
|
# Install dependencies
|
|
180
196
|
npm install
|
|
181
197
|
|
|
182
|
-
# Run the
|
|
198
|
+
# Run the dev server (& tests)
|
|
183
199
|
npm run dev
|
|
184
200
|
|
|
185
201
|
# Build for production
|