Skip to content

Commit

Permalink
draw:drawvertex can add or remove points; handle point removal
Browse files Browse the repository at this point in the history
  • Loading branch information
savage13 committed Aug 22, 2024
1 parent 4a6ffc0 commit b64c6c5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/AppMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,17 @@ export default class AppMap extends mixins(MixinUtil) {
'draw:drawstart': () => {
this.drawVertexLayers = [];
},
'draw:drawvertex': () => {
this.drawVertexLayers.push(this.map.activeLayer);
'draw:drawvertex': (item: any) => {
// Determine if points have been added or removed
const n0 = this.drawVertexLayers.length
const n1 = item.layers.getLayers().length;
if (n0 + 1 == n1) // Point Added
this.drawVertexLayers.push(this.map.activeLayer);
else if (n0 - 1 == n1) // Point Removed (Assume 'delete last point' clicked)
this.drawVertexLayers.pop()
else {
console.log(`Unknown state encountered currentPoints(edit) ${n1} layers ${n0}`)

Check failure on line 899 in src/components/AppMap.ts

View workflow job for this annotation

GitHub Actions / deploy

Unexpected console statement
}
},
'draw:edited': (e: any) => {
e.layers.eachLayer((layer: L.Marker | L.Polyline) => {
Expand Down

0 comments on commit b64c6c5

Please sign in to comment.