Skip to content

Commit

Permalink
Merge pull request #9343 from camptocamp/wmts-opacity-geo-6913
Browse files Browse the repository at this point in the history
Fix WMTS layer opacity from permalink
  • Loading branch information
sbrunner committed May 8, 2024
2 parents acc1393 + c8f4cec commit 3bf6a7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/datasource/ExternalDataSourcesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export class ExternalDatSourcesManager {
* @param {any} capabilities WMTS Capabilities definition
* @param {string} wmtsUrl The WMTS capabilities url
*/
createAndAddDataSourceFromWMTSCapability(layer, capabilities, wmtsUrl, opacity) {
createAndAddDataSourceFromWMTSCapability(layer, capabilities, wmtsUrl) {
const id = getId(layer);

// (1) No need to do anything if there's already a WMTS data source (and its
Expand Down Expand Up @@ -489,7 +489,6 @@ export class ExternalDatSourcesManager {

// (4) Create and add the OL layer
const layerObj = this.ngeoLayerHelper_.createWMTSLayerFromCapabilititesObj(capabilities, layer);
layerObj.setOpacity(opacity);
this.addLayer_(layerObj);

// (5) Add data source to ngeo collection
Expand Down
2 changes: 1 addition & 1 deletion src/import/wmtsCapabilityLayertreeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class Controller {
throw new Error('Missing url');
}
const manager = this.gmfExternalDataSourcesManager_;
manager.createAndAddDataSourceFromWMTSCapability(layer, this.capabilities, this.url, 1);
manager.createAndAddDataSourceFromWMTSCapability(layer, this.capabilities, this.url);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/permalink/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,9 @@ PermalinkService.prototype.initLayers_ = function () {
);
if (treeCtrl.layer) {
if (opacity !== undefined) {
treeCtrl.layer.setOpacity(opacity);
this.$timeout_(() => {
treeCtrl.layer.setOpacity(opacity);
}, 100);
}
// === Set the gmfLayerBeingSwipe layer ===
if (
Expand Down Expand Up @@ -1704,8 +1706,7 @@ PermalinkService.prototype.initExternalDataSources_ = function () {
gmfExtDSManager.createAndAddDataSourceFromWMTSCapability(
layerCap,
response.capabilities,
response.url,
this.ngeoStateManager_.getInitialNumberValue(`${ParamPrefix.TREE_OPACITY}${layerName}`)
response.url
);
} else {
// TODO - handle 'not found' layer in capabilities
Expand Down

0 comments on commit 3bf6a7e

Please sign in to comment.