Skip to content

Commit

Permalink
v1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
www committed Mar 24, 2017
2 parents a0f2f33 + a2b8ff7 commit f7b5edf
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 10 deletions.
8 changes: 7 additions & 1 deletion dist/angular-openlayers-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,13 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa
// set visibility
if (isDefined(oldProperties) &&
isBoolean(properties.visible) &&
properties.visible !== oldProperties.visible || isNewLayer(olLayer)) {
(
properties.visible !== oldProperties.visible ||
isNewLayer(olLayer) ||
// to make sure the underlying ol3 object is always synched
olLayer.getVisible() !== properties.visible
)
) {
olLayer.setVisible(properties.visible);
}

Expand Down
6 changes: 3 additions & 3 deletions dist/angular-openlayers-directive.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/angular-openlayers-directive.min.no-header.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion dist/angular-openlayers-directive.pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,13 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
// set visibility
if (isDefined(oldProperties) &&
isBoolean(properties.visible) &&
properties.visible !== oldProperties.visible || isNewLayer(olLayer)) {
(
properties.visible !== oldProperties.visible ||
isNewLayer(olLayer) ||
// to make sure the underlying ol3 object is always synched
olLayer.getVisible() !== properties.visible
)
) {
olLayer.setVisible(properties.visible);
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
},
"scripts": {
"test": "grunt build && grunt karma:unit",
"test.watch": "grunt build && grunt karma:dev",
"build": "grunt build",
"prepublish": "npm run build",
"postpublish": "publish-latest",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"main": "dist/angular-openlayers-directive",
"version": "1.19.2"
"version": "1.19.3"
}
8 changes: 7 additions & 1 deletion src/directives/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
// set visibility
if (isDefined(oldProperties) &&
isBoolean(properties.visible) &&
properties.visible !== oldProperties.visible || isNewLayer(olLayer)) {
(
properties.visible !== oldProperties.visible ||
isNewLayer(olLayer) ||
// to make sure the underlying ol3 object is always synched
olLayer.getVisible() !== properties.visible
)
) {
olLayer.setVisible(properties.visible);
}

Expand Down
66 changes: 66 additions & 0 deletions test/unit/layersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,4 +486,70 @@ describe('Directive: openlayers layers', function() {

});

describe('when updating the visibility', function() {
beforeEach(function() {
scope.layers = [
{
identifier: 'LAYER-SPAIN',
name: 'Spain',
visible: true,
source: {
type: 'GeoJSON',
url: 'json/ESP.geo.json'
}
}
];

var element = angular
.element('<openlayers custom-layers="true">' +
'<ol-layer ol-layer-properties="layer" ng-repeat="layer in layers"></ol-layer>' +
'</openlayers>');
element = $compile(element)(scope);
scope.$digest();
});

it('the layer should be set to visible', function() {
olData.getMap().then(function(olMap) {
var layers = olMap.getLayers().getArray();
expect(layers[0].getVisible()).toBeTruthy();
});
});

it('should correctly set the layer to visible false', function() {
// act
scope.layers[0].visible = false;
scope.$digest();

// assert
olData.getMap().then(function(olMap) {
var layers = olMap.getLayers().getArray();
expect(layers[0].getVisible()).toBeFalsy();
});

});

it('should sync visibility of the underlying OL3 object if not aligned', function() {
// assume our object is set to visible false
scope.layers[0].visible = false;
scope.$digest();

olData.getMap().then(function(olMap) {
var layers = olMap.getLayers().getArray();
// set visibility on the underlying ol3 object
layers[0].setVisible(true);
});

scope.layers[0].name = 'Bla bla'; // just to kick on change detection
scope.$digest();

// assert
olData.getMap().then(function(olMap) {
var layers = olMap.getLayers().getArray();
expect(layers[0].getVisible()).toBeFalsy();
});

});

});

});

0 comments on commit f7b5edf

Please sign in to comment.