Enable the snapping grid controls when farmOS-map is used for editing #335

This commit is contained in:
Symbioquine 2020-07-31 07:49:48 -07:00 committed by Michael Stenta
parent fd6e45ad19
commit 01e1f05c46
2 changed files with 17 additions and 10 deletions

View File

@ -25,6 +25,9 @@
instance.addBehavior('edit');
var layer = instance.edit.layer;
}
// Add the snappingGrid behavior.
instance.addBehavior('snappingGrid');
}
// Enable the line/polygon measure behavior.

View File

@ -19,11 +19,7 @@
};
this.movementLayer = this.instance.addLayer('vector', opts);
// Make the layer editable.
this.instance.addBehavior('edit', { layer: this.movementLayer });
// Add measure behavior.
this.instance.addBehavior('measure', { layer: this.movementLayer});
this.addEditBehaviors();
},
// Update the assets current location map layer.
@ -73,11 +69,7 @@
};
this.movementLayer = this.instance.addLayer('wkt', opts);
// Make the layer editable.
this.instance.addBehavior('edit', { layer: this.movementLayer });
// Add measure behavior.
this.instance.addBehavior('measure', { layer: this.movementLayer});
this.addEditBehaviors();
// Zoom to all vector layers.
this.instance.zoomToVectors();
@ -94,6 +86,18 @@
});
},
// Adds behaviors for editing movements
addEditBehaviors() {
// Make the layer editable.
this.instance.addBehavior('edit', { layer: this.movementLayer });
// Add the snappingGrid behavior.
this.instance.addBehavior('snappingGrid');
// Add measure behavior.
this.instance.addBehavior('measure', { layer: this.movementLayer});
},
// Make sure this runs after farmOS.map.behaviors.wkt.
weight: 101,
};