@zwishing/emap 0.3.0 → 0.3.2

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 CHANGED
@@ -7,6 +7,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.2] - 2026-05-23
11
+
12
+ ### Added
13
+
14
+ - `EditToolbar` now accepts explicit `controls`, allowing examples and apps to
15
+ compose toolbar buttons directly from existing UI controls.
16
+ - Added `draw-snap-clear.html` to demonstrate that draw snapping markers clear
17
+ as soon as the cursor leaves the configured threshold.
18
+
19
+ ### Changed
20
+
21
+ - Renamed the batch snapping example from `snap.html` to `snap-layer.html` to
22
+ make its `snapLayer` purpose explicit.
23
+ - Upgraded the direct `mproj` dependency to `^0.1.2` while keeping the browser
24
+ bundle self-contained.
25
+
26
+ ### Fixed
27
+
28
+ - Draw snapping now clears stale snap overlays when the cursor moves outside the
29
+ snap threshold before the first vertex is placed.
30
+ - Vertex editing can snap dragged nodes to other features' vertices or edges,
31
+ controlled by `snapThreshold`, `snapToVertex`, and `snapToEdge`.
32
+ - `DrawFeatureControl` reapplies its own handler options when switching between
33
+ draw buttons in a shared toolbar.
34
+ - `projectLayer` normalizes common EPSG aliases (`EPSG:3857`, `EPSG:900913`,
35
+ `EPSG:102100`, `EPSG:4326`) to mapshaper's browser-safe CRS names.
36
+
37
+ ## [0.3.1] - 2026-05-21
38
+
39
+ ### Changed
40
+
41
+ - `boxSelect` now behaves like an active selection tool by default: plain
42
+ left-drag starts a rectangular selection and replaces the previous selection,
43
+ while `Shift`+drag adds to the existing selection and `Shift`+`Alt`+drag
44
+ toggles matching features.
45
+ - `transform` edit mode keeps map panning available outside already-selected
46
+ features; dragging selected features still starts a transform session.
47
+ - When pan or translate-transform mode is active and the pointer hovers an
48
+ already-selected feature, the canvas cursor now switches to `move`; active
49
+ map dragging still uses `grabbing`.
50
+
10
51
  ## [0.3.0] - 2026-05-21
11
52
 
12
53
  ### Added
package/FEATURES.md CHANGED
@@ -134,7 +134,7 @@ these directly without using bundled UI controls.
134
134
  | `map.dragPan` | Pointer drag map panning |
135
135
  | `map.scrollZoom` | Wheel zoom |
136
136
  | `map.clickSelect` | Click selection |
137
- | `map.boxSelect` | Shift-drag rectangular selection |
137
+ | `map.boxSelect` | Active-tool rectangular selection |
138
138
  | `map.lassoSelect` | Free-form lasso selection |
139
139
  | `map.vertexEdit` | Topology-aware vertex editing |
140
140
  | `map.drawFeature` | Point, polyline, and polygon drawing |
package/README.md CHANGED
@@ -189,7 +189,6 @@ them directly from your own UI instead of adding `BoxSelectControl`,
189
189
  ```ts
190
190
  map.boxSelect.setOptions({
191
191
  layers: ['district-fill'],
192
- dragActivator: 'shift',
193
192
  dragThreshold: 4,
194
193
  });
195
194
  map.boxSelect.enable();
@@ -229,7 +228,7 @@ Available named handlers:
229
228
  | `map.dragPan` | Pointer drag map panning |
230
229
  | `map.scrollZoom` | Wheel zoom |
231
230
  | `map.clickSelect` | Click selection |
232
- | `map.boxSelect` | Shift-drag rectangular selection |
231
+ | `map.boxSelect` | Active-tool rectangular selection |
233
232
  | `map.lassoSelect` | Free-form lasso selection |
234
233
  | `map.vertexEdit` | Topology-aware vertex editing |
235
234
  | `map.drawFeature` | Point, polyline, and polygon drawing |
@@ -282,11 +281,12 @@ const clearButton = document.querySelector<HTMLButtonElement>('[data-tool="clear
282
281
 
283
282
  map.boxSelect.setOptions({
284
283
  layers: ['district-fill'],
285
- dragActivator: 'shift',
286
284
  dragThreshold: 4,
287
- mode: 'replace',
288
285
  });
289
286
 
287
+ // Plain drag replaces the current selection. Shift+drag adds to it;
288
+ // Shift+Alt+drag toggles matching features.
289
+
290
290
  function activateBoxSelect() {
291
291
  map.lassoSelect.disable();
292
292
  map.vertexEdit.disable();
@@ -15,7 +15,7 @@ export interface BoxSelectStyle {
15
15
  export interface BoxSelectHandlerOptions extends SelectHandlerOptions {
16
16
  /** Min drag diagonal (px) before a release counts as a box. Default 4. */
17
17
  dragThreshold?: number;
18
- /** Combo that must be held at pointerdown to start. Default 'shift'. */
18
+ /** Combo that must be held at pointerdown to start. Default 'none'. */
19
19
  dragActivator?: ModifierCombo;
20
20
  style?: BoxSelectStyle;
21
21
  }
@@ -25,8 +25,7 @@ export interface BoxSelectHandlerOptions extends SelectHandlerOptions {
25
25
  * `_canvasContainer`, and on release past `dragThreshold` runs
26
26
  * `queryFeatures(bbox)` → `select(mode)`. Mode is resolved by stripping the
27
27
  * activator then matching `modifiers` — reproducing the legacy
28
- * `BoxSelectControl` behavior exactly. Mutually exclusive with `lassoSelect`
29
- * (enforced in HandlerManager — a later task).
28
+ * active-tool selection behavior. Mutually exclusive with `lassoSelect`.
30
29
  */
31
30
  export declare class BoxSelectHandler extends EventDispatcher implements Handler<BoxSelectHandlerOptions> {
32
31
  private _map;
@@ -4,6 +4,10 @@ export interface DragPanOptions {
4
4
  /** Reserve shift+drag for higher-level handlers (P2b selection). Default true. */
5
5
  skipShiftDrag: boolean;
6
6
  }
7
+ type Point = {
8
+ x: number;
9
+ y: number;
10
+ };
7
11
  /**
8
12
  * Named `dragPan` handler. Phase 2a: pan logic lives in `handlePointer`,
9
13
  * driven by HandlerManager's single pointer-listener arbiter — the handler
@@ -16,8 +20,10 @@ export declare class DragPanHandler extends EventDispatcher implements Handler<D
16
20
  private _enabled;
17
21
  private _dragging;
18
22
  private _last;
23
+ private _hoverPoint;
19
24
  private _onGestureStart?;
20
- constructor(opts?: Partial<DragPanOptions>, onGestureStart?: () => void);
25
+ private _isHoveringSelected?;
26
+ constructor(opts?: Partial<DragPanOptions>, onGestureStart?: () => void, isHoveringSelected?: (point: Point) => boolean);
21
27
  enable(): void;
22
28
  disable(): void;
23
29
  isEnabled(): boolean;
@@ -26,3 +32,4 @@ export declare class DragPanHandler extends EventDispatcher implements Handler<D
26
32
  getCursor(): string | null;
27
33
  handlePointer(ev: NormalizedPointerEvent): HandlerResult;
28
34
  }
35
+ export {};
@@ -24,6 +24,11 @@ export declare class TransformFeatureHandler implements Handler<TransformFeature
24
24
  private _translate;
25
25
  private _affine;
26
26
  private _lastMap;
27
+ private _hoveringSelected;
28
+ /** Injected by HandlerManager.register (cursor recompute on mode flips). */
29
+ _manager?: {
30
+ refreshCursor(): void;
31
+ };
27
32
  private _prevAngle;
28
33
  private _prevDist;
29
34
  private _onKeyDownBound;
@@ -35,6 +40,7 @@ export declare class TransformFeatureHandler implements Handler<TransformFeature
35
40
  isEnabled(): boolean;
36
41
  setOptions(o: Partial<TransformFeatureOptions>): void;
37
42
  getOptions(): Readonly<TransformFeatureOptions>;
43
+ getCursor(): string | null;
38
44
  private _cancelSession;
39
45
  private _onKeyDown;
40
46
  handlePointer(ev: NormalizedPointerEvent): HandlerResult;
@@ -3,6 +3,12 @@ import { Emap } from '../../map/map';
3
3
  export interface VertexEditOptions {
4
4
  /** Polygon hover fill. Default 'rgba(0,0,0,0.15)'. */
5
5
  polygonFillColor?: string;
6
+ /** Pixel threshold for snapping a dragged vertex to another feature. Default 10. */
7
+ snapThreshold?: number;
8
+ /** Snap dragged vertices to other features' existing vertices. Default true. */
9
+ snapToVertex?: boolean;
10
+ /** Snap dragged vertices to other features' edges. Default true. */
11
+ snapToEdge?: boolean;
6
12
  }
7
13
  export declare class VertexEditHandler implements Handler<VertexEditOptions> {
8
14
  readonly name = "vertexEdit";
@@ -23,6 +29,9 @@ export declare class VertexEditHandler implements Handler<VertexEditOptions> {
23
29
  private _neighborShapes;
24
30
  /** Coordinate of the dragged node before mouse-down, captured for VertexMoveCommand. */
25
31
  private _dragFromCoords;
32
+ private _snapThreshold;
33
+ private _snapToVertex;
34
+ private _snapToEdge;
26
35
  private _onMapMoveBound;
27
36
  constructor(map: Emap, opts?: VertexEditOptions);
28
37
  isEnabled(): boolean;
@@ -94,5 +103,7 @@ export declare class VertexEditHandler implements Handler<VertexEditOptions> {
94
103
  private _onMouseDown;
95
104
  private _pushVertexInsertCommand;
96
105
  private _handleDrag;
106
+ private _resolveDragCoords;
107
+ private _findDragSnapTarget;
97
108
  private _finishDrag;
98
109
  }