(e: KeyboardEvent)
| 252 | if (map.getSource("draw-points")) map.removeSource("draw-points"); |
| 253 | } catch {} |
| 254 | return; |
| 255 | } |
| 256 | map.getCanvas().style.cursor = "crosshair"; |
| 257 | console.log("[Virdis Draw] Drawing mode started"); |
| 258 | const handleClick = (e: mapboxgl.MapMouseEvent) => { |
| 259 | const vertex: [number, number] = [e.lngLat.lng, e.lngLat.lat]; |
| 260 | console.log("[Virdis Draw] Vertex added:", vertex); |
| 261 | setDrawVertices((prev) => { |
| 262 | const updated = [...prev, vertex]; |
| 263 | console.log("[Virdis Draw] Total vertices:", updated.length); |
| 264 | return updated; |
| 265 | }); |
| 266 | }; |
| 267 | const handleKeyDown = (e: KeyboardEvent) => { |
| 268 | if (e.key === "Escape") { |
| 269 | console.log("[Virdis Draw] Drawing cancelled (Escape)"); |
| 270 | setDrawMode(false); setDrawVertices([]); |
| 271 | } |
| 272 | if (e.key === "Backspace") { |
| 273 | e.preventDefault(); |
| 274 | console.log("[Virdis Draw] Undo last vertex (Backspace)"); |
| 275 | setDrawVertices((prev) => prev.length > 0 ? prev.slice(0, -1) : prev); |
| 276 | } |
| 277 | if (e.key === "Enter") { |
| 278 | setDrawVertices((prev) => { |
| 279 | if (prev.length >= 3) { |
| 280 | const closedCoords = [...prev, prev[0]]; |
| 281 | const geometry = { type: "Polygon" as const, coordinates: [closedCoords] }; |
nothing calls this directly
no outgoing calls
no test coverage detected