@sakuzu/maplibre-gl-draw 2.0.0 → 2.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/CHANGELOG.md +119 -1
- package/README.ja.md +48 -35
- package/README.md +52 -36
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/api/datasets.d.ts +5 -0
- package/dist/api/draw.d.ts +6 -4
- package/dist/api/draw.js +6 -4
- package/dist/api/events.d.ts +10 -0
- package/dist/api/impl/create-draw.js +1 -1
- package/dist/api/impl/datasets.js +1 -0
- package/dist/api/impl/events.js +2 -1
- package/dist/api/impl/extension-host.js +4 -1
- package/dist/api/impl/options.js +58 -29
- package/dist/dataset/dataset.js +3 -0
- package/dist/dataset/retained.js +19 -18
- package/dist/dataset/selection.d.ts +3 -3
- package/dist/dataset/selection.js +3 -7
- package/dist/dataset/table-source.js +13 -11
- package/dist/dataset/types.d.ts +2 -0
- package/dist/dispatcher/input-router.js +2 -1
- package/dist/dispatcher/normalizer.js +19 -2
- package/dist/geometry/geojson.d.ts +4 -0
- package/dist/geometry/geojson.js +20 -11
- package/dist/index.d.ts +14 -0
- package/dist/view/layer/attach.d.ts +11 -5
- package/dist/view/layer/attach.js +85 -9
- package/dist/view/layer/custom-layer.js +2 -1
- package/dist/view/layer/drape-planner.d.ts +3 -0
- package/dist/view/layer/drape-planner.js +9 -7
- package/dist/view/layer/frame-render.js +2 -3
- package/dist/view/layer/frame-state.d.ts +3 -0
- package/dist/view/layer/frame-state.js +2 -1
- package/dist/view/layer/gl-state.d.ts +2 -3
- package/dist/view/layer/gl-state.js +2 -3
- package/dist/view/renderers/line/dash.d.ts +27 -0
- package/dist/view/renderers/line/dash.js +23 -12
- package/dist/view/terrain/drape/bin-store.d.ts +11 -2
- package/dist/view/terrain/drape/bin-store.js +26 -2
- package/dist/view/terrain/drape/binning.d.ts +32 -0
- package/dist/view/terrain/drape/binning.js +15 -7
- package/dist/view/terrain/drape/geometry.d.ts +27 -0
- package/dist/view/terrain/drape/geometry.js +57 -6
- package/dist/view/terrain/drape/pass.d.ts +8 -3
- package/dist/view/terrain/drape/pass.js +39 -28
- package/dist/view/terrain/drape/renderer.d.ts +13 -0
- package/dist/view/terrain/drape/renderer.js +157 -30
- package/package.json +22 -10
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,122 @@ the project follows semantic versioning.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.1.1] - 2026-10-02
|
|
10
|
+
|
|
11
|
+
Three fixes to the lines drawn on the terrain: their thickness on a
|
|
12
|
+
high-DPI display, their thickness between the vertices, and dashed lines
|
|
13
|
+
that sank into the ground. Nothing else changes.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- With the terrain on, a solid line or the outline of a polygon was drawn
|
|
18
|
+
half as thick on a high-DPI display (a device pixel ratio of 2) as
|
|
19
|
+
without the terrain, when its width follows the zoom. It is now as
|
|
20
|
+
thick with the terrain as without it.
|
|
21
|
+
- With the terrain on and the camera pitched, a solid line looked like a
|
|
22
|
+
string of beads: it was thinner between its vertices than at them, and
|
|
23
|
+
the outline of a polygon was thinner along its edges. Its thickness is
|
|
24
|
+
now the same all along.
|
|
25
|
+
- With the terrain on and the camera pitched, a dashed or dotted line,
|
|
26
|
+
and the dashed outline of a polygon, sank into the ground on the side
|
|
27
|
+
towards the camera and showed a jagged edge. They are now painted on
|
|
28
|
+
the ground like solid lines, with the same dashes as without the
|
|
29
|
+
terrain.
|
|
30
|
+
|
|
31
|
+
## [2.1.0] - 2026-10-01
|
|
32
|
+
|
|
33
|
+
The standard UI package, the documentation site with twenty examples and
|
|
34
|
+
the playground on it, the event `options.changed`,
|
|
35
|
+
`Dataset.getStyleRule()`, and fixes to the order of the layers after a
|
|
36
|
+
diffed `setStyle`, to a drag across the antimeridian on the globe, to the
|
|
37
|
+
`/geometry` functions given a feature, and to `scaleWithZoom` changed at
|
|
38
|
+
runtime. Nothing changes incompatibly.
|
|
39
|
+
|
|
40
|
+
### Added in 2.1.0
|
|
41
|
+
|
|
42
|
+
- The event `options.changed`, with `{ options, previous }`: what
|
|
43
|
+
`draw.options.get()` returns after and before a `draw.options.update`
|
|
44
|
+
that changed a value. An update that changes nothing fires nothing,
|
|
45
|
+
and the event is not a change of the document, so it fires no
|
|
46
|
+
`document.changed`.
|
|
47
|
+
- Twenty examples built with the standard UI, each with its page
|
|
48
|
+
on the site: `get-started`, `style-features`, `feature-properties`,
|
|
49
|
+
`layers-and-groups`, `style-rules-and-legend`, `snapping-and-tracing`,
|
|
50
|
+
`geometry-operations`, `images`, `editing-shapes`, `zoom-and-scale`,
|
|
51
|
+
`save-and-load`, `terrain`, `globe`, `200000-features`, `datasets`,
|
|
52
|
+
`columnar-data-in-a-worker`, `read-only-viewer`, `plugins`,
|
|
53
|
+
`custom-feature-types` and `custom-ui`. Their basemap menu offers the
|
|
54
|
+
OpenFreeMap styles.
|
|
55
|
+
- A sample of Overture Maps data for the examples, in
|
|
56
|
+
`examples/public/data/` (not in the package): the 10,477 buildings and
|
|
57
|
+
the 17,558 places of central Tokyo east of the station, as GeoJSON and
|
|
58
|
+
GeoParquet. `npm run data:overture` (`scripts/fetch-overture-sample.mjs`)
|
|
59
|
+
writes them again. The buildings are under the ODbL and the places
|
|
60
|
+
under the CDLA Permissive 2.0;
|
|
61
|
+
`THIRD_PARTY_NOTICES.md` and `examples/public/data/README.md` record
|
|
62
|
+
the attribution and the licenses of every source. The `datasets`,
|
|
63
|
+
`columnar-data-in-a-worker` and `style-rules-and-legend` examples show
|
|
64
|
+
them.
|
|
65
|
+
- `Dataset.getStyleRule()`, the style rule of a dataset: the
|
|
66
|
+
one last given to `setStyleRule`, or the one given to `datasets.add`,
|
|
67
|
+
or `undefined` when there is none. A legend of the datasets reads it.
|
|
68
|
+
|
|
69
|
+
### Changed in 2.1.0
|
|
70
|
+
|
|
71
|
+
- The site (<https://sakuzu.github.io/maplibre-gl-draw/>) is
|
|
72
|
+
the documentation site: getting started and the guides in English and
|
|
73
|
+
Japanese, a gallery of the examples, each on a page that runs it
|
|
74
|
+
beside its code, the playground under `/playground/` and the API
|
|
75
|
+
reference under `/api/`, which opens with where each resource of
|
|
76
|
+
`Draw` is. The examples with buttons of their own (`basic`,
|
|
77
|
+
`save-load`, `style-rules`, `snapping-and-geometry`, `read-only`,
|
|
78
|
+
`plugin`, `custom-feature-type`, `large-data` and `table-worker`) are
|
|
79
|
+
replaced by the examples of the gallery, and their addresses, like
|
|
80
|
+
those of the HTML pages of the API reference of 1.0 and 2.0, redirect
|
|
81
|
+
to the pages that took their place. `npm run site:dev` serves the site
|
|
82
|
+
with the examples and the playground for a local check.
|
|
83
|
+
- The playground is built on the standard UI, with the tools
|
|
84
|
+
and the inspector sections of a plugin and of a custom feature type,
|
|
85
|
+
and the switches that are not tools on Shift and a letter. It opens on
|
|
86
|
+
an overview of every look one layer can hold; `?plain` opens it empty.
|
|
87
|
+
- The dev server of the examples (`npm run dev`) moves from
|
|
88
|
+
port 3000 to 3200, and that of the playground
|
|
89
|
+
(`npm run dev:playground`) from 3001 to 3300. They and
|
|
90
|
+
`npm run test:e2e` need the standard UI built first
|
|
91
|
+
(`npm run ui:build`).
|
|
92
|
+
- No sample geometry of the examples, the scenes of the
|
|
93
|
+
playground or the development page of the standard UI lies over the
|
|
94
|
+
Imperial Palace, its East Gardens or Kitanomaru Park. Each page keeps
|
|
95
|
+
its data in a `data.ts` of its own, and a test walks all of it and
|
|
96
|
+
fails when anything reaches into that area.
|
|
97
|
+
|
|
98
|
+
### Fixed in 2.1.0
|
|
99
|
+
|
|
100
|
+
- After `map.setStyle` in its default diff mode, the drawing is
|
|
101
|
+
on top of the map again. maplibre leaves custom layers out of the
|
|
102
|
+
style it diffs, so the layers of the new style were added above the
|
|
103
|
+
drawing and hid it. The layers of the instance now move back on top on
|
|
104
|
+
every `style.load`, in their order, with the map layers placed between
|
|
105
|
+
them; a full `setStyle` (`diff: false`) works as before.
|
|
106
|
+
- `draw.options.update({ scaleWithZoom })` reaches the drawing
|
|
107
|
+
modes at once. They kept the value given to `createDraw`, so a feature
|
|
108
|
+
drawn after the option was turned off still got a reference zoom
|
|
109
|
+
(`maplibre-gl-draw:createdZoom`), and one drawn after it was turned on
|
|
110
|
+
got none.
|
|
111
|
+
- The functions of `/geometry` take a feature of the drawing as it
|
|
112
|
+
is, as documented. A feature whose `type` names a geometry type
|
|
113
|
+
(`Polygon`, `LineString` and so on) was read as a geometry and threw a
|
|
114
|
+
`GeometryError` (`invalid-input`); an object with a `geometry` member
|
|
115
|
+
that is a geometry is now read as a feature first, whatever its own
|
|
116
|
+
`type`.
|
|
117
|
+
- On the globe, a freehand stroke drawn across the antimeridian is
|
|
118
|
+
drawn as the stroke alone. The globe gives the pointer longitudes in
|
|
119
|
+
[-180, 180], so where the pointer crossed the line (or slid along the
|
|
120
|
+
edge of the sphere past it) the next point of the stroke was 360
|
|
121
|
+
degrees from the one before, and a line went once round the globe
|
|
122
|
+
along the parallel. The coordinates of a press now run on past 180 as
|
|
123
|
+
they do on the flat map.
|
|
124
|
+
|
|
9
125
|
## [2.0.0] - 2026-09-30
|
|
10
126
|
|
|
11
127
|
2.0.0 redesigns the public API around resources and their collections.
|
|
@@ -1052,6 +1168,8 @@ available from Kasika, Inc.
|
|
|
1052
1168
|
- A read-only mode and an interaction lock.
|
|
1053
1169
|
- Plugins, custom modes and custom feature types.
|
|
1054
1170
|
|
|
1055
|
-
[Unreleased]: https://github.com/sakuzu/maplibre-gl-draw/compare/v2.
|
|
1171
|
+
[Unreleased]: https://github.com/sakuzu/maplibre-gl-draw/compare/v2.1.1...HEAD
|
|
1172
|
+
[2.1.1]: https://github.com/sakuzu/maplibre-gl-draw/compare/v2.1.0...v2.1.1
|
|
1173
|
+
[2.1.0]: https://github.com/sakuzu/maplibre-gl-draw/compare/v2.0.0...v2.1.0
|
|
1056
1174
|
[2.0.0]: https://github.com/sakuzu/maplibre-gl-draw/compare/v1.0.0...v2.0.0
|
|
1057
1175
|
[1.0.0]: https://github.com/sakuzu/maplibre-gl-draw/releases/tag/v1.0.0
|
package/README.ja.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
このページの正は英語版 ([README.md](README.md)) です。
|
|
12
12
|
|
|
13
|
-

|
|
14
14
|
|
|
15
15
|
## 機能
|
|
16
16
|
|
|
@@ -122,28 +122,36 @@ GeoJSON の properties を持つので、ファイルはコードで読む地物
|
|
|
122
122
|
ブラウザーですぐに試せます。インストールは要りません。
|
|
123
123
|
|
|
124
124
|
- [プレイグラウンド][demo]
|
|
125
|
-
- すべての機能を 1
|
|
126
|
-
- [
|
|
127
|
-
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
- すべての機能を 1 つの画面で。標準の UI 付き
|
|
126
|
+
- [例][examples]
|
|
127
|
+
- 20 の例。どれも、例を動かすページにそのコードを添えています
|
|
128
|
+
|
|
129
|
+
例の一部を挙げます。
|
|
130
|
+
|
|
131
|
+
- [Get started][ex-get-started]
|
|
132
|
+
- 地物を描き、選び、パネルで直す
|
|
133
|
+
- [Save and load][ex-save-and-load]
|
|
134
|
+
- GeoJSON と独自形式、地図に落としたファイル、読み込みで外された地物
|
|
135
|
+
- [Style rules and legend][ex-style-rules-and-legend]
|
|
131
136
|
- 属性の値で色を分ける 4 種類の規則と凡例
|
|
132
|
-
- [
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
- [
|
|
136
|
-
- 3D
|
|
137
|
-
- [
|
|
138
|
-
-
|
|
139
|
-
- [
|
|
140
|
-
-
|
|
141
|
-
- [
|
|
137
|
+
- [Snapping and tracing][ex-snapping-and-tracing] と
|
|
138
|
+
[Geometry operations][ex-geometry-operations]
|
|
139
|
+
- 吸着、境界のなぞり、結合、交差、差、分割、バッファー
|
|
140
|
+
- [Terrain][ex-terrain]
|
|
141
|
+
- 3D 地形の上での描画と編集
|
|
142
|
+
- [Read-only viewer][ex-read-only-viewer]
|
|
143
|
+
- 見るための描画。閲覧専用、操作のロック、クリックした地物の属性
|
|
144
|
+
- [Plugins][ex-plugins]
|
|
145
|
+
- 独自のモードを持つプラグインと、標準の UI に足すその道具
|
|
146
|
+
- [Custom feature types][ex-custom-feature-types]
|
|
142
147
|
- 独自の描き方、当たり判定、範囲選択を持つ地物の型
|
|
143
|
-
- [
|
|
144
|
-
-
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
- [Datasets][ex-datasets]
|
|
149
|
+
- Overture Maps の東京都心の建物と場所を描画の下と上に。場所は
|
|
150
|
+
見えている範囲の分を取り寄せる
|
|
151
|
+
- [Columnar data in a Worker][ex-columnar-data-in-a-worker]
|
|
152
|
+
- 同じ建物を Worker で GeoParquet から読み込み、列のまま描く
|
|
153
|
+
- [Build your own UI][ex-custom-ui]
|
|
154
|
+
- 標準の UI を使わない、自分の道具のバーとパネル
|
|
147
155
|
|
|
148
156
|
## インストール
|
|
149
157
|
|
|
@@ -191,8 +199,9 @@ document.querySelector('#save')?.addEventListener('click', () => {
|
|
|
191
199
|
});
|
|
192
200
|
```
|
|
193
201
|
|
|
194
|
-
|
|
195
|
-
[
|
|
202
|
+
[はじめかた](docs/getting-started.ja.md) では、このページを順を追って
|
|
203
|
+
作ります。[Get started][ex-get-started] の例は、自分のボタンの代わりに
|
|
204
|
+
標準の UI を地図に重ねます。
|
|
196
205
|
|
|
197
206
|
## 入口
|
|
198
207
|
|
|
@@ -231,7 +240,8 @@ document.querySelector('#save')?.addEventListener('click', () => {
|
|
|
231
240
|
[docs/README.ja.md](docs/README.ja.md) に、はじめかた、手引き、
|
|
232
241
|
リファレンス、内部の文書を読む順に並べています。1.0、mapbox-gl-draw、
|
|
233
242
|
terra-draw から移る場合は [移行](docs/guides/migrating.ja.md) を参照して
|
|
234
|
-
ください。
|
|
243
|
+
ください。[API リファレンス][api] のメインのエントリーのページは、
|
|
244
|
+
インスタンスの資源とそれぞれのメソッドの一覧から始まります。
|
|
235
245
|
|
|
236
246
|
## 開発に参加する
|
|
237
247
|
|
|
@@ -254,15 +264,18 @@ AGPL が製品に合わない場合は、Kasika, Inc. (可視化技研株式会
|
|
|
254
264
|
|
|
255
265
|
[maplibre]: https://maplibre.org/maplibre-gl-js/docs/
|
|
256
266
|
[custom-layer]: https://maplibre.org/maplibre-gl-js/docs/API/interfaces/CustomLayerInterface/
|
|
257
|
-
[demo]: https://sakuzu.github.io/maplibre-gl-draw/
|
|
267
|
+
[demo]: https://sakuzu.github.io/maplibre-gl-draw/playground/
|
|
258
268
|
[api]: https://sakuzu.github.io/maplibre-gl-draw/api/
|
|
259
|
-
[
|
|
260
|
-
[ex-
|
|
261
|
-
[ex-
|
|
262
|
-
[ex-
|
|
263
|
-
[ex-
|
|
264
|
-
[ex-
|
|
265
|
-
[ex-
|
|
266
|
-
[ex-
|
|
267
|
-
[ex-
|
|
268
|
-
[ex-
|
|
269
|
+
[examples]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/
|
|
270
|
+
[ex-get-started]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/get-started.html
|
|
271
|
+
[ex-save-and-load]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/save-and-load.html
|
|
272
|
+
[ex-style-rules-and-legend]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/style-rules-and-legend.html
|
|
273
|
+
[ex-snapping-and-tracing]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/snapping-and-tracing.html
|
|
274
|
+
[ex-geometry-operations]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/geometry-operations.html
|
|
275
|
+
[ex-terrain]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/terrain.html
|
|
276
|
+
[ex-read-only-viewer]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/read-only-viewer.html
|
|
277
|
+
[ex-plugins]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/plugins.html
|
|
278
|
+
[ex-custom-feature-types]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/custom-feature-types.html
|
|
279
|
+
[ex-datasets]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/datasets.html
|
|
280
|
+
[ex-columnar-data-in-a-worker]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/columnar-data-in-a-worker.html
|
|
281
|
+
[ex-custom-ui]: https://sakuzu.github.io/maplibre-gl-draw/ja/examples/custom-ui.html
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ it does on a flat map.
|
|
|
8
8
|
[Demos][demo] | [Documentation](docs/README.md) | [API reference][api] |
|
|
9
9
|
[日本語](README.ja.md)
|
|
10
10
|
|
|
11
|
-

|
|
12
12
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
@@ -126,31 +126,41 @@ returns ([plugins](docs/guides/plugins.md),
|
|
|
126
126
|
Try them in the browser, with nothing to install.
|
|
127
127
|
|
|
128
128
|
- [Playground][demo]
|
|
129
|
-
- Every feature in one editor, with
|
|
130
|
-
- [
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
- [
|
|
129
|
+
- Every feature in one editor, with the standard UI
|
|
130
|
+
- [Examples][examples]
|
|
131
|
+
- Twenty examples, each on a page that runs it beside its code
|
|
132
|
+
|
|
133
|
+
Among the examples:
|
|
134
|
+
|
|
135
|
+
- [Get started][ex-get-started]
|
|
136
|
+
- Drawing, selecting and changing features in the panel
|
|
137
|
+
- [Save and load][ex-save-and-load]
|
|
138
|
+
- GeoJSON and the native format, files dropped on the map, the
|
|
139
|
+
features a load leaves out
|
|
140
|
+
- [Style rules and legend][ex-style-rules-and-legend]
|
|
136
141
|
- The four kinds of style rule that color features by a property, with
|
|
137
142
|
a legend
|
|
138
|
-
- [Snapping and
|
|
139
|
-
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
|
|
147
|
-
- [
|
|
143
|
+
- [Snapping and tracing][ex-snapping-and-tracing] and
|
|
144
|
+
[geometry operations][ex-geometry-operations]
|
|
145
|
+
- Snapping, tracing a boundary, union, intersection, difference, split
|
|
146
|
+
and buffer
|
|
147
|
+
- [Terrain][ex-terrain]
|
|
148
|
+
- Drawing and editing on 3D terrain
|
|
149
|
+
- [Read-only viewer][ex-read-only-viewer]
|
|
150
|
+
- A drawing to look at: read-only, the interaction lock, the attributes
|
|
151
|
+
of the feature clicked
|
|
152
|
+
- [Plugins][ex-plugins]
|
|
153
|
+
- A plugin with a mode of its own, and its tool in the standard UI
|
|
154
|
+
- [Custom feature types][ex-custom-feature-types]
|
|
148
155
|
- A kind of feature with its own drawing, hit test and box selection
|
|
149
|
-
- [Datasets][ex-
|
|
150
|
-
-
|
|
151
|
-
|
|
152
|
-
- [
|
|
153
|
-
-
|
|
156
|
+
- [Datasets][ex-datasets]
|
|
157
|
+
- The buildings and places of central Tokyo from Overture Maps, under
|
|
158
|
+
and over the drawing, with places fetched for the part in view
|
|
159
|
+
- [Columnar data in a Worker][ex-columnar-data-in-a-worker]
|
|
160
|
+
- The same buildings read from GeoParquet in a Worker and drawn from
|
|
161
|
+
their columns
|
|
162
|
+
- [Build your own UI][ex-custom-ui]
|
|
163
|
+
- A toolbar and a panel of your own, without the standard UI
|
|
154
164
|
|
|
155
165
|
## Installation
|
|
156
166
|
|
|
@@ -198,8 +208,9 @@ document.querySelector('#save')?.addEventListener('click', () => {
|
|
|
198
208
|
});
|
|
199
209
|
```
|
|
200
210
|
|
|
201
|
-
|
|
202
|
-
[
|
|
211
|
+
[Getting started](docs/getting-started.md) builds this page step by
|
|
212
|
+
step, and the [Get started][ex-get-started] example lays the standard UI
|
|
213
|
+
over the map in place of your own buttons.
|
|
203
214
|
|
|
204
215
|
## Entry points
|
|
205
216
|
|
|
@@ -239,6 +250,8 @@ Import from the main entry unless you need one of the others.
|
|
|
239
250
|
[docs/README.md](docs/README.md) lists every document in reading order:
|
|
240
251
|
getting started, the guides, the reference and the internals. Moving from
|
|
241
252
|
1.0, mapbox-gl-draw or terra-draw? See [migrating](docs/guides/migrating.md).
|
|
253
|
+
The page of the main entry in the [API reference][api] opens with a list
|
|
254
|
+
of the resources of the instance and the methods each one has.
|
|
242
255
|
|
|
243
256
|
## Contributing
|
|
244
257
|
|
|
@@ -261,15 +274,18 @@ The notices of the third-party code this package contains are in
|
|
|
261
274
|
|
|
262
275
|
[maplibre]: https://maplibre.org/maplibre-gl-js/docs/
|
|
263
276
|
[custom-layer]: https://maplibre.org/maplibre-gl-js/docs/API/interfaces/CustomLayerInterface/
|
|
264
|
-
[demo]: https://sakuzu.github.io/maplibre-gl-draw/
|
|
277
|
+
[demo]: https://sakuzu.github.io/maplibre-gl-draw/playground/
|
|
265
278
|
[api]: https://sakuzu.github.io/maplibre-gl-draw/api/
|
|
266
|
-
[
|
|
267
|
-
[ex-
|
|
268
|
-
[ex-
|
|
269
|
-
[ex-
|
|
270
|
-
[ex-
|
|
271
|
-
[ex-
|
|
272
|
-
[ex-
|
|
273
|
-
[ex-
|
|
274
|
-
[ex-
|
|
275
|
-
[ex-
|
|
279
|
+
[examples]: https://sakuzu.github.io/maplibre-gl-draw/examples/
|
|
280
|
+
[ex-get-started]: https://sakuzu.github.io/maplibre-gl-draw/examples/get-started.html
|
|
281
|
+
[ex-save-and-load]: https://sakuzu.github.io/maplibre-gl-draw/examples/save-and-load.html
|
|
282
|
+
[ex-style-rules-and-legend]: https://sakuzu.github.io/maplibre-gl-draw/examples/style-rules-and-legend.html
|
|
283
|
+
[ex-snapping-and-tracing]: https://sakuzu.github.io/maplibre-gl-draw/examples/snapping-and-tracing.html
|
|
284
|
+
[ex-geometry-operations]: https://sakuzu.github.io/maplibre-gl-draw/examples/geometry-operations.html
|
|
285
|
+
[ex-terrain]: https://sakuzu.github.io/maplibre-gl-draw/examples/terrain.html
|
|
286
|
+
[ex-read-only-viewer]: https://sakuzu.github.io/maplibre-gl-draw/examples/read-only-viewer.html
|
|
287
|
+
[ex-plugins]: https://sakuzu.github.io/maplibre-gl-draw/examples/plugins.html
|
|
288
|
+
[ex-custom-feature-types]: https://sakuzu.github.io/maplibre-gl-draw/examples/custom-feature-types.html
|
|
289
|
+
[ex-datasets]: https://sakuzu.github.io/maplibre-gl-draw/examples/datasets.html
|
|
290
|
+
[ex-columnar-data-in-a-worker]: https://sakuzu.github.io/maplibre-gl-draw/examples/columnar-data-in-a-worker.html
|
|
291
|
+
[ex-custom-ui]: https://sakuzu.github.io/maplibre-gl-draw/examples/custom-ui.html
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -273,3 +273,32 @@ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
273
273
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
274
274
|
THIS SOFTWARE.
|
|
275
275
|
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Sample data of the examples (Overture Maps)
|
|
280
|
+
|
|
281
|
+
The examples of the repository (`examples/`, not part of the package)
|
|
282
|
+
show buildings and places of central Tokyo from Overture Maps, in
|
|
283
|
+
`examples/public/data/`. `scripts/fetch-overture-sample.mjs` extracts
|
|
284
|
+
them, and `examples/public/data/README.md` records the release, the
|
|
285
|
+
extent, the counts and the sources of the rows.
|
|
286
|
+
|
|
287
|
+
Attribution: © OpenStreetMap contributors, Overture Maps Foundation.
|
|
288
|
+
|
|
289
|
+
- The buildings (`tokyo-buildings.geojson` and `tokyo-buildings.parquet`)
|
|
290
|
+
are a database derived from Overture's buildings theme, under the Open
|
|
291
|
+
Database License 1.0 (ODbL): <https://opendatacommons.org/licenses/odbl/1-0/>.
|
|
292
|
+
Its rows come from OpenStreetMap and Microsoft's Global ML Building
|
|
293
|
+
Footprints (ODbL), and from Qian Shi, et al., A First High-quality
|
|
294
|
+
Vector Data of Buildings in East Asian Countries Based on a
|
|
295
|
+
Comprehensive Large-scale Mapping Framework, Zenodo,
|
|
296
|
+
doi:10.5281/zenodo.8174931 (CC BY 4.0)
|
|
297
|
+
- The places (`tokyo-places.geojson`) come from Overture's places theme,
|
|
298
|
+
under the Community Data License Agreement Permissive 2.0:
|
|
299
|
+
<https://cdla.dev/permissive-2-0/>. Rows from Foursquare are under the
|
|
300
|
+
Apache License 2.0 (Copyright 2024 Foursquare Labs, Inc.), and rows from
|
|
301
|
+
AllThePlaces under CC0 1.0
|
|
302
|
+
|
|
303
|
+
The terms of every source are on
|
|
304
|
+
<https://docs.overturemaps.org/attribution/>.
|
package/dist/api/datasets.d.ts
CHANGED
|
@@ -154,6 +154,11 @@ export interface Dataset {
|
|
|
154
154
|
setTable(table: Table | PreparedTable): void;
|
|
155
155
|
/** Replaces the style rule; `undefined` removes it. */
|
|
156
156
|
setStyleRule(rule: StyleRule | undefined): void;
|
|
157
|
+
/**
|
|
158
|
+
* The style rule, or `undefined` when none is set: the rule last given to `setStyleRule`, or
|
|
159
|
+
* the one given to `datasets.add` when it was not replaced.
|
|
160
|
+
*/
|
|
161
|
+
getStyleRule(): StyleRule | undefined;
|
|
157
162
|
/** Replaces the scale factor and the opacity by zoom; `null` removes them. */
|
|
158
163
|
setZoomScale(zoomScale: DatasetZoomScale | null): void;
|
|
159
164
|
/** The scale factor and the opacity by zoom, or `null` when none is set. */
|
package/dist/api/draw.d.ts
CHANGED
|
@@ -123,10 +123,12 @@ export interface Draw {
|
|
|
123
123
|
/**
|
|
124
124
|
* Puts a draw instance on a map and returns it.
|
|
125
125
|
*
|
|
126
|
-
* It can be called before, while or after the map loads. The layers are added
|
|
127
|
-
* style accepts them
|
|
128
|
-
*
|
|
129
|
-
*
|
|
126
|
+
* It can be called before, while or after the map loads. The layers are added on top of the map
|
|
127
|
+
* as soon as the style accepts them. After `setStyle`, with or without `diff`, they are on top
|
|
128
|
+
* again: added again after a full replacement, and moved above the layers of the new style after
|
|
129
|
+
* a diff. A layer added to the map later goes above them and stays there until the style changes.
|
|
130
|
+
* Unless `initDefaultLayer: false` is given, the document starts with one empty layer. Several
|
|
131
|
+
* instances can share a page, each on its own map.
|
|
130
132
|
*
|
|
131
133
|
* @param map - The map to draw on
|
|
132
134
|
* @param options - The options; every one can be omitted
|
package/dist/api/draw.js
CHANGED
|
@@ -4,10 +4,12 @@ import { createDraw as createDrawInstance } from './impl/create-draw.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Puts a draw instance on a map and returns it.
|
|
6
6
|
*
|
|
7
|
-
* It can be called before, while or after the map loads. The layers are added
|
|
8
|
-
* style accepts them
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* It can be called before, while or after the map loads. The layers are added on top of the map
|
|
8
|
+
* as soon as the style accepts them. After `setStyle`, with or without `diff`, they are on top
|
|
9
|
+
* again: added again after a full replacement, and moved above the layers of the new style after
|
|
10
|
+
* a diff. A layer added to the map later goes above them and stays there until the style changes.
|
|
11
|
+
* Unless `initDefaultLayer: false` is given, the document starts with one empty layer. Several
|
|
12
|
+
* instances can share a page, each on its own map.
|
|
11
13
|
*
|
|
12
14
|
* @param map - The map to draw on
|
|
13
15
|
* @param options - The options; every one can be omitted
|
package/dist/api/events.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { DrawError } from './errors.js';
|
|
|
10
10
|
import type { Hit } from './extension/provider.js';
|
|
11
11
|
import type { UpdateSource } from './extension/store.js';
|
|
12
12
|
import type { Feature, FeatureInput, FileData, Group, Layer, LoadResult, Metadata, MoveTarget } from './model.js';
|
|
13
|
+
import type { RuntimeOptions } from './options.js';
|
|
13
14
|
import type { LayerStackEntry, Mode, Selection, SelectionType, SnapResult, VertexSelection } from './state.js';
|
|
14
15
|
/** A point on the screen, as `[x, y]` in CSS pixels. */
|
|
15
16
|
export type ScreenPoint = [number, number];
|
|
@@ -231,6 +232,15 @@ export interface DrawEvents {
|
|
|
231
232
|
'interactionLock.changed': {
|
|
232
233
|
locked: boolean;
|
|
233
234
|
};
|
|
235
|
+
/**
|
|
236
|
+
* `draw.options.update` changed the options; `options` and `previous` are what
|
|
237
|
+
* `draw.options.get()` returns after and before the change. An update that leaves every
|
|
238
|
+
* value as it was does not fire it
|
|
239
|
+
*/
|
|
240
|
+
'options.changed': {
|
|
241
|
+
options: Readonly<RuntimeOptions>;
|
|
242
|
+
previous: Readonly<RuntimeOptions>;
|
|
243
|
+
};
|
|
234
244
|
/** The snapping target changed */
|
|
235
245
|
'snap.changed': {
|
|
236
246
|
result: SnapResult | null;
|
|
@@ -24,7 +24,7 @@ const ASYNC_MEMBERS = new Set(['document.load', 'document.loadMany']);
|
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
26
|
export function createDrawOnEngine(engine, options = {}, setExternalEntry = () => { }) {
|
|
27
|
-
const drawOptions = createOptions(engine, options, setExternalEntry);
|
|
27
|
+
const drawOptions = createOptions(engine, options, setExternalEntry, (payload) => engine.events.emit('options.changed', payload));
|
|
28
28
|
drawOptions.applyCreation();
|
|
29
29
|
const { context, modeManager, events, map } = engine;
|
|
30
30
|
const { store } = context;
|
|
@@ -258,6 +258,7 @@ export function wrapDataset(dataset) {
|
|
|
258
258
|
throw invalidInput('The rule must be an object');
|
|
259
259
|
dataset.setStyleRule(rule);
|
|
260
260
|
},
|
|
261
|
+
getStyleRule: () => dataset.getStyleRule(),
|
|
261
262
|
setZoomScale(zoomScale) {
|
|
262
263
|
if (zoomScale !== null)
|
|
263
264
|
checkFunction(zoomScale, 'zoomScale');
|
package/dist/api/impl/events.js
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* `document.changed` with the whole
|
|
11
11
|
* change when the transaction changed the document. The engine announces the rest
|
|
12
12
|
* on its internal emitter (snapping, clicks, images, the stacking order, failed loads,
|
|
13
|
-
* drags), and each is passed on under its name here.
|
|
13
|
+
* drags), and each is passed on under its name here. `options.changed` comes from
|
|
14
|
+
* `draw.options`, which emits it on the same hub.
|
|
14
15
|
*/
|
|
15
16
|
import { DRAW_PROPERTY_KEYS } from '../../shared/properties.js';
|
|
16
17
|
import { geometryFromCoordinates } from '../../shared/utils/coordinates.js';
|
|
@@ -164,7 +164,10 @@ export function createExtensionHost(deps) {
|
|
|
164
164
|
},
|
|
165
165
|
getWritableLayerId: context.getWritableLayerId,
|
|
166
166
|
generateId: context.generateFeatureId,
|
|
167
|
-
|
|
167
|
+
// Read when a feature is committed, so a change of the option applies at once
|
|
168
|
+
get scaleWithZoom() {
|
|
169
|
+
return context.options.scaleWithZoom;
|
|
170
|
+
},
|
|
168
171
|
selectionStyle: context.selectionStyle,
|
|
169
172
|
boxSelectionStyle: context.renderingConfig.boxSelectionStyle,
|
|
170
173
|
notifyDrawCommit: (feature) => announceDrawCommit(feature),
|