Skip to content

Commit

Permalink
Merge pull request #295 from Geoportail-Luxembourg/elemoine_measureopen
Browse files Browse the repository at this point in the history
Disable the measure tools when the measure menu is closed
  • Loading branch information
Éric Lemoine committed Mar 3, 2015
2 parents 69696f4 + c3d2315 commit 518b5a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion geoportailv3/static/js/measure/measuredirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ app.measureDirective = function(appMeasureTemplateUrl) {
return {
restrict: 'E',
scope: {
'map': '=appMeasureMap'
'map': '=appMeasureMap',
'active': '=appMeasureActive'
},
controller: 'AppMeasureController',
controllerAs: 'ctrl',
Expand Down Expand Up @@ -118,6 +119,18 @@ app.MeasureController = function($scope, ngeoDecorateInteraction) {
measureAzimut.setActive(false);
ngeoDecorateInteraction(measureAzimut);
map.addInteraction(measureAzimut);

// Watch the "active" property, and disable the measure interactions
// when "active" gets set to false.
$scope.$watch(goog.bind(function() {
return this['active'];
}, this), goog.bind(function(newVal) {
if (newVal === false) {
this['measureLength'].active = false;
this['measureArea'].active = false;
this['measureAzimut'].active = false;
}
}, this));
};


Expand Down
2 changes: 1 addition & 1 deletion geoportailv3/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h2 translate>infos</h2>
</li>
<li class="hidden-xs measure icon" ng-class="mainCtrl.measureOpen ? 'active' : ''">
<a href translate ngeo-btn ng-model="mainCtrl.measureOpen">measure</a>
<app-measure app-measure-map="::mainCtrl.map"></app-measure>
<app-measure app-measure-map="::mainCtrl.map" app-measure-active="mainCtrl.measureOpen"></app-measure>
</li>
<li class="hidden-xs print icon" ng-class="mainCtrl.printOpen ? 'active' : ''">
<a href translate ngeo-btn ng-model="mainCtrl.printOpen">print</a>
Expand Down

0 comments on commit 518b5a7

Please sign in to comment.