diff --git a/modules/farm/farm_map/js/farmOS.map.behaviors.wkt.js b/modules/farm/farm_map/js/farmOS.map.behaviors.wkt.js index 5643333e6..0b8869ba9 100644 --- a/modules/farm/farm_map/js/farmOS.map.behaviors.wkt.js +++ b/modules/farm/farm_map/js/farmOS.map.behaviors.wkt.js @@ -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. diff --git a/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js b/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js index acf680145..0af05af89 100644 --- a/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js +++ b/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js @@ -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, };