Skip to content

Commit

Permalink
Add more draw-on-map polygon options
Browse files Browse the repository at this point in the history
  • Loading branch information
ByronCinNZ committed Jun 17, 2024
1 parent 614e9a9 commit e2d4a56
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@
type: "LineString",
source: source
});
ctrl.drawPointInteraction = new ol.interaction.Draw({
type: "Point",
source: source
});
ctrl.drawCircleInteraction = new ol.interaction.Draw({
type: "Circle",
source: source
});
ctrl.modifyInteraction = new ol.interaction.Modify({
features: source.getFeaturesCollection()
});
Expand All @@ -112,14 +120,20 @@
// add our layer&interactions to the map
olDecorateInteraction(ctrl.drawInteraction);
olDecorateInteraction(ctrl.drawLineInteraction);
olDecorateInteraction(ctrl.drawPointInteraction);
olDecorateInteraction(ctrl.drawCircleInteraction);
olDecorateInteraction(ctrl.modifyInteraction);
ctrl.drawInteraction.active = false;
ctrl.drawLineInteraction.active = false;
ctrl.drawPointInteraction.active = false;
ctrl.drawCircleInteraction.active = false;
ctrl.modifyInteraction.active = false;

// add interactions to map
ctrl.map.addInteraction(ctrl.drawInteraction);
ctrl.map.addInteraction(ctrl.drawLineInteraction);
ctrl.map.addInteraction(ctrl.drawPointInteraction);
ctrl.map.addInteraction(ctrl.drawCircleInteraction);
ctrl.map.addInteraction(ctrl.modifyInteraction);

// clear existing features on draw end & save feature
Expand All @@ -129,6 +143,8 @@
ctrl.updateOutput(event.feature);
ctrl.drawInteraction.active = false;
ctrl.drawLineInteraction.active = false;
ctrl.drawPointInteraction.active = false;
ctrl.drawCircleInteraction.active = false;
$scope.$digest();

// prevent interference by zoom interaction
Expand All @@ -142,6 +158,8 @@
}
ctrl.drawInteraction.on("drawend", handleDrawEnd);
ctrl.drawLineInteraction.on("drawend", handleDrawEnd);
ctrl.drawPointInteraction.on("drawend", handleDrawEnd);
ctrl.drawCircleInteraction.on("drawend", handleDrawEnd);

// update output on modify end
ctrl.modifyInteraction.on("modifyend", function (event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
<span class="fa fa-pencil"></span>&nbsp;
<span translate>Line</span>
</button>
<button
class="btn btn-default"
gi-btn="active"
ng-model="ctrl.drawPointInteraction.active"
>
<span class="fa fa-pencil"></span>&nbsp;
<span translate>Point</span>
</button>
<!-- <button
class="btn btn-default"
gi-btn="active"
ng-model="ctrl.drawCircleInteraction.active"
>
<span class="fa fa-pencil"></span>&nbsp;
<span translate>Circle</span>
</button> -->
</div>
</div>
<button
Expand Down

0 comments on commit e2d4a56

Please sign in to comment.