Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the opacity slider, don't download unneeded tiles #5106

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildtools/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ new webpack.LoaderOptionsPlugin({

module.exports = {
mode: 'development',
// devtool: 'eval',
devtool: 'inline-cheap-source-map', // 'cheap-eval-source-map',
output: {
filename: '[name].js'
},
Expand Down
12 changes: 11 additions & 1 deletion contribs/gmf/src/backgroundlayerselector/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ Controller.prototype.handleThemesChange_ = function() {
const opacityLayer = layers.find(layer => layer.get('label') === this.opacityOptions);
if (opacityLayer !== undefined) {
this.setOpacityBgLayer(opacityLayer);
this.opacityLayer = opacityLayer;

// Reorder for the UI the bgArray copy with the opacity layer at the end
this.bgLayers = this.bgLayers.slice();
Expand All @@ -207,6 +206,7 @@ Controller.prototype.getSetBgLayerOpacity = function(val) {
if (val !== undefined) {
this.opacityLayer.setOpacity(val);
this.opacityLayer.setVisible(val !== 0);
this.bgLayer.setVisible(val !== 1);
}
return this.opacityLayer.getOpacity();
};
Expand All @@ -216,8 +216,14 @@ Controller.prototype.getSetBgLayerOpacity = function(val) {
* @param {boolean=} opt_silent Do not notify listeners.
*/
Controller.prototype.setLayer = function(layer, opt_silent) {
const opacity = this.opacityLayer ? this.opacityLayer.getOpacity() : 0;
this.bgLayer = layer;
this.backgroundLayerMgr_.set(this.map, layer);
layer.setVisible(opacity !== 1);
if (this.opacityLayer) {
this.opacityLayer.setVisible(opacity !== 0);
this.opacityLayer.setOpacity(opacity);
}
if (!opt_silent && this.select) {
this.select();
}
Expand All @@ -228,6 +234,10 @@ Controller.prototype.setLayer = function(layer, opt_silent) {
* @param {import("ol/layer/Base.js").default} layer The opacity background layer.
*/
Controller.prototype.setOpacityBgLayer = function(layer) {
this.opacityLayer = layer;
const opacity = layer.getOpacity();
this.opacityLayer.setVisible(opacity !== 0);
this.bgLayer.setVisible(opacity !== 1);
this.backgroundLayerMgr_.setOpacityBgLayer(this.map, layer);
};

Expand Down
5 changes: 2 additions & 3 deletions src/map/BackgroundLayerMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,8 @@ export class MapBackgroundLayerManager extends olObservable {
const bgGroup = this.ngeoLayerHelper_.getGroupFromMap(map, BACKGROUNDLAYERGROUP_NAME);
const previous = bgGroup.getLayers().remove(this.getOpacityBgLayer(map));
const ZIndex = -100;
const opacity = previous ? previous.getOpacity() : 0;
layer.setOpacity(opacity);
layer.setVisible(opacity !== 0);
layer.setOpacity(previous ? previous.getOpacity() : 0);
layer.setVisible(previous ? previous.getVisible() : true);
layer.setZIndex(ZIndex);
this.ngeoLayerHelper_.setZIndexToFirstLevelChildren(layer, ZIndex);

Expand Down