Skip to content

Commit

Permalink
Merge pull request #4851 from camptocamp/GSGMF-934
Browse files Browse the repository at this point in the history
Update the rotation input from the map rotation events
  • Loading branch information
fredj committed Apr 26, 2019
2 parents 617beed + 3bb89cf commit b09f88a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions contribs/gmf/src/print/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ exports.Controller_ = class {
* Init the controller
*/
$onInit() {

olEvents.listen(this.map.getView(), 'change:rotation', (event) => {
this.updateRotation_(Math.round(olMath.toDegrees(event.target.getRotation())));
});

// Clear the capabilities if the roleId changes
this.$scope_.$watch(() => this.gmfAuthenticationService_.getRoleId(), () => {
this.gmfPrintState_.state = exports.PrintStateEnum.CAPABILITIES_NOT_LOADED;
Expand Down Expand Up @@ -794,11 +799,7 @@ exports.Controller_ = class {
* @param {number} rotation The optional new rotation value in degrees.
*/
setRotation(rotation) {
this.rotation = olMath.clamp(rotation, -180, 180);

// sync all the inputs
this.rotationInput_.val(this.rotation.toString());

this.updateRotation_(rotation);
// Render the map to update the postcompose mask or rotate the map.
if (this.rotateMask) {
this.map.render();
Expand All @@ -807,6 +808,15 @@ exports.Controller_ = class {
}
}

/**
* Set the current rotation value.
* @param {number} rotation The optional new rotation value in degrees.
*/
updateRotation_(rotation) {
this.rotation = olMath.clamp(rotation, -180, 180);
// sync all the inputs
this.rotationInput_.val(this.rotation.toString());
}

/**
* Calculate the angle and the sense of rotation between two lines. One from the
Expand Down

0 comments on commit b09f88a

Please sign in to comment.