Skip to content

Commit

Permalink
Merge pull request #265 from auckenth/allow-smooth-layer-reload-for-W…
Browse files Browse the repository at this point in the history
…MS-layers

fix(olHelpers): allow smooth layer reload when updating params of WMS layer
  • Loading branch information
juristr committed May 19, 2016
2 parents a942cf1 + 275584f commit 505e207
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/services/olHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
url: source.url,
attributions: createAttribution(source),
crossOrigin: (typeof source.crossOrigin === 'undefined') ? 'anonymous' : source.crossOrigin,
params: source.params,
params: deepCopy(source.params),
ratio: source.ratio
});
break;
Expand All @@ -251,7 +251,7 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $

var wmsConfiguration = {
crossOrigin: (typeof source.crossOrigin === 'undefined') ? 'anonymous' : source.crossOrigin,
params: source.params,
params: deepCopy(source.params),
attributions: createAttribution(source)
};

Expand Down Expand Up @@ -573,6 +573,17 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
return oSource;
};

var deepCopy = function(oldObj) {
var newObj = oldObj;
if (oldObj && typeof oldObj === 'object') {
newObj = Object.prototype.toString.call(oldObj) === '[object Array]' ? [] : {};
for (var i in oldObj) {
newObj[i] = deepCopy(oldObj[i]);
}
}
return newObj;
};

var createAttribution = function(source) {
var attributions = [];
if (isDefined(source.attribution)) {
Expand Down

0 comments on commit 505e207

Please sign in to comment.