map-boundary-editor 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/LICENSE +19 -0
- package/README.md +152 -0
- package/dist/map-boundary-editor.js +7194 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2025 heritechie
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# map-boundary-editor
|
|
2
|
+
|
|
3
|
+
**map-boundary-editor** is a generic, embeddable, map-based boundary editor
|
|
4
|
+
implemented as a Web Component.
|
|
5
|
+
|
|
6
|
+
It allows users to visually draw and edit a geographic boundary
|
|
7
|
+
and outputs a standard **GeoJSON** representation that can be reused
|
|
8
|
+
across different map engines and backend systems.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why map-boundary-editor?
|
|
13
|
+
|
|
14
|
+
Many applications need users to define geographic areas:
|
|
15
|
+
|
|
16
|
+
- delivery zones
|
|
17
|
+
- service coverage
|
|
18
|
+
- eligibility rules
|
|
19
|
+
- geofencing configuration
|
|
20
|
+
|
|
21
|
+
Most teams end up rebuilding the same map drawing logic again and again,
|
|
22
|
+
tightly coupled to a specific map provider.
|
|
23
|
+
|
|
24
|
+
**map-boundary-editor** solves this by providing:
|
|
25
|
+
|
|
26
|
+
- a reusable boundary authoring UI
|
|
27
|
+
- a stable and minimal API
|
|
28
|
+
- engine-agnostic GeoJSON output
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Features (v0.1)
|
|
33
|
+
|
|
34
|
+
- Draw, edit, and delete a polygon boundary
|
|
35
|
+
- Leaflet-based (no API key required)
|
|
36
|
+
- Outputs standard GeoJSON (RFC 7946)
|
|
37
|
+
- Framework-agnostic (Web Component)
|
|
38
|
+
- Easy to embed in any web application
|
|
39
|
+
|
|
40
|
+
> Note: v0.1 supports a single boundary only.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### Via npm
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install map-boundary-editor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Via script tag
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<script src="map-boundary-editor.min.js"></script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Basic Usage
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<map-boundary-editor style="width: 800px; height: 500px;"></map-boundary-editor>
|
|
66
|
+
|
|
67
|
+
<script>
|
|
68
|
+
const editor = document.querySelector("map-boundary-editor");
|
|
69
|
+
|
|
70
|
+
editor.addEventListener("change", (e) => {
|
|
71
|
+
console.log("GeoJSON:", e.detail.geojson);
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Loading an Existing Boundary
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
editor.setGeoJSON({
|
|
82
|
+
type: "Feature",
|
|
83
|
+
geometry: {
|
|
84
|
+
type: "Polygon",
|
|
85
|
+
coordinates: [
|
|
86
|
+
[
|
|
87
|
+
[106.8166, -6.2],
|
|
88
|
+
[106.82, -6.21],
|
|
89
|
+
[106.83, -6.205],
|
|
90
|
+
[106.8166, -6.2],
|
|
91
|
+
],
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
properties: {},
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Public API (v0.1)
|
|
101
|
+
|
|
102
|
+
`getGeoJSON(): GeoJSON`
|
|
103
|
+
|
|
104
|
+
Returns the current boundary as GeoJSON.
|
|
105
|
+
|
|
106
|
+
`setGeoJSON(geojson: GeoJSON): void`
|
|
107
|
+
|
|
108
|
+
Loads a boundary from GeoJSON and renders it on the map.
|
|
109
|
+
|
|
110
|
+
`clear(): void`
|
|
111
|
+
|
|
112
|
+
Removes the current boundary.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Events
|
|
117
|
+
|
|
118
|
+
`change`
|
|
119
|
+
|
|
120
|
+
Fired whenever the boundary is created, edited, or deleted.
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
editor.addEventListener("change", (e) => {
|
|
124
|
+
console.log(e.detail.geojson);
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Data Format
|
|
131
|
+
|
|
132
|
+
The editor uses GeoJSON as its data contract.
|
|
133
|
+
|
|
134
|
+
GeoJSON is treated as the single source of truth and is intentionally decoupled
|
|
135
|
+
from any specific map engine.
|
|
136
|
+
|
|
137
|
+
The output is compatible with:
|
|
138
|
+
|
|
139
|
+
- Google Maps Data Layer
|
|
140
|
+
- Mapbox / MapLibre
|
|
141
|
+
- Backend GIS libraries (PostGIS, Shapely, Turf.js)
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Roadmap
|
|
146
|
+
|
|
147
|
+
- v0.2: multiple boundaries (FeatureCollection)
|
|
148
|
+
- v0.3: read-only mode
|
|
149
|
+
- v0.4: additional map engine adapters (MapLibre, Google Maps)
|
|
150
|
+
- v1.0: stable API
|
|
151
|
+
|
|
152
|
+
---
|