leaflet-anvil 0.2.3 → 0.3.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/README.md CHANGED
@@ -9,12 +9,12 @@ TypeScript features, and support for complex geometric operations like Union and
9
9
  ## Features
10
10
 
11
11
  - **Drawing Modes**: Marker, Polylines, Polygons, Rectangles, Squares, Triangles, Circles, and Freehand Drawing.
12
- - **Editing Tools**: Drag, Scale, Rotate, and Vertex editing.
12
+ - **Editing Tools**: Drag, Scale, Rotate, vertex editing, and full-layer topology editing.
13
13
  - **Geometric Operations**:
14
14
  - `Union`: Merge two polygons into one.
15
15
  - `Subtract`: Subtract one polygon from another.
16
16
  - `Cut` & `Split`: Cut lines or split areas.
17
- - **Smart Helpers**: Snapping to existing points and Magnetic mode.
17
+ - **Smart Helpers**: Snapping to existing points, topology-aware splitting, and linked vertices across touching layers while editing.
18
18
  - **Event-driven**: Easy integration through a consistent event system.
19
19
 
20
20
  ## Installation
@@ -38,7 +38,6 @@ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
38
38
  const anvil = new Anvil(map, {
39
39
  snapping: true,
40
40
  snapDistance: 15,
41
- magnetic: true,
42
41
  preventSelfIntersection: true,
43
42
  controlPosition: 'topleft',
44
43
  modes: [
@@ -70,7 +69,8 @@ Activation via `anvil.enable(AnvilMode.Name)` or through the UI toolbar:
70
69
  | | `Square` | Creates a square with a fixed aspect ratio. |
71
70
  | | `Triangle` | Creates a triangle. |
72
71
  | | `Circle` | Creates a circle with radius determination. |
73
- | **Transform** | `Edit` | Edit individual vertices. |
72
+ | **Transform** | `Edit` | Edit selected geometries vertex-by-vertex. |
73
+ | | `Topology` | Edit the whole layer group with linked vertices across touching layers. |
74
74
  | | `Drag` | Move entire geometries on the map. |
75
75
  | | `Scale` | Proportional resizing (scaling). |
76
76
  | | `Rotate` | Rotate geometries around their center. |
@@ -86,7 +86,6 @@ Activation via `anvil.enable(AnvilMode.Name)` or through the UI toolbar:
86
86
  |:--------------------------|:----------|:------------|:---------------------------------------------------------------------------------------------------------------------|
87
87
  | `snapping` | `boolean` | `false` | **Snapping:** If `true`, new points automatically snap to existing vertices of other geometries. |
88
88
  | `snapDistance` | `number` | `10` | **Snap Distance:** Determines the distance in pixels at which a point "jumps" to the nearest existing vertex. |
89
- | `magnetic` | `boolean` | `false` | **Magnetism:** Enhances snapping behavior. Points are actively attracted once they enter the radius. |
90
89
  | `preventSelfIntersection` | `boolean` | `false` | **Validation:** Prevents edges from self-intersecting in polygons and lines. Blocks invalid segments during drawing. |
91
90
  | `pathOptions` | `object` | `Leaflet` | Global fallback styles for path-based layers such as polygons, lines, rectangles and circles. |
92
91
  | `ghostPathOptions` | `object` | `Inherited` | Global fallback styles for temporary preview geometry while drawing. |
@@ -107,7 +106,7 @@ Supported per-mode keys:
107
106
  - `ghostPathOptions`: Temporary preview style while drawing.
108
107
  - `vertexOptions`: Marker options for marker-based modes.
109
108
  - `handleOptions`: Options for helper handles such as polygon close handles or edit handles.
110
- - `selectionPathOptions`: Highlight style for selected/active geometry in modes like `Edit`, `Drag`, `Scale`, `Rotate`, `Union` and `Subtract`.
109
+ - `selectionPathOptions`: Highlight style for selected/active geometry in modes like `Edit`, `Topology`, `Drag`, `Scale`, `Rotate`, `Union` and `Subtract`.
111
110
 
112
111
  ```typescript
113
112
  const anvil = new Anvil(map, {
@@ -148,6 +147,17 @@ const anvil = new Anvil(map, {
148
147
  radius: 6,
149
148
  },
150
149
  },
150
+ [AnvilMode.Topology]: {
151
+ selectionPathOptions: {
152
+ color: '#0891b2',
153
+ weight: 3,
154
+ },
155
+ handleOptions: {
156
+ color: '#0891b2',
157
+ fillColor: '#ecfeff',
158
+ radius: 5,
159
+ },
160
+ },
151
161
  [AnvilMode.Rotate]: {
152
162
  selectionPathOptions: {
153
163
  color: '#8b5cf6',
@@ -169,7 +179,7 @@ const anvil = new Anvil(map, {
169
179
  ```
170
180
 
171
181
  If you want to style the active highlight of interaction modes, use `selectionPathOptions`.
172
- That is what controls the temporary emphasis color when a geometry is selected in modes such as `Edit` or while actively transforming it in `Drag`, `Scale`, `Rotate`, `Union` or `Subtract`.
182
+ That is what controls the temporary emphasis color when a geometry is selected in modes such as `Edit` or while actively transforming it in `Topology`, `Drag`, `Scale`, `Rotate`, `Union` or `Subtract`.
173
183
 
174
184
  ### Custom Toolbar Tooltips
175
185
 
package/dist/index.d.mts CHANGED
@@ -17,6 +17,7 @@ declare enum AnvilMode {
17
17
  Union = "union",
18
18
  Subtract = "subtract",
19
19
  Edit = "edit",
20
+ Topology = "topology",
20
21
  Delete = "delete",
21
22
  Off = "off"
22
23
  }
@@ -31,7 +32,6 @@ interface AnvilOptions {
31
32
  layerGroup?: L.FeatureGroup;
32
33
  snapping?: boolean;
33
34
  snapDistance?: number;
34
- magnetic?: boolean;
35
35
  freehandTolerance?: number;
36
36
  preventSelfIntersection?: boolean;
37
37
  pathOptions?: L.PathOptions;
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ declare enum AnvilMode {
17
17
  Union = "union",
18
18
  Subtract = "subtract",
19
19
  Edit = "edit",
20
+ Topology = "topology",
20
21
  Delete = "delete",
21
22
  Off = "off"
22
23
  }
@@ -31,7 +32,6 @@ interface AnvilOptions {
31
32
  layerGroup?: L.FeatureGroup;
32
33
  snapping?: boolean;
33
34
  snapDistance?: number;
34
- magnetic?: boolean;
35
35
  freehandTolerance?: number;
36
36
  preventSelfIntersection?: boolean;
37
37
  pathOptions?: L.PathOptions;