Skip to content

Commit

Permalink
Closes #86
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Geiger committed Sep 8, 2021
1 parent ea77261 commit 7784a0a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
12 changes: 5 additions & 7 deletions js/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = function ($, app) {
EventEmitter.call(this);
if (!settings) { return; }
$.extend(true, this, settings); // copy all properties from `settings` into `this`
this.transparency = 0;
if (this.index == undefined) {
this.index = 0;
}
Expand Down Expand Up @@ -142,6 +141,8 @@ module.exports = function ($, app) {
app.map.addLayer(this.createOpenLayersLayer())
}

this.setTransparency()

vectorServices = [ 'vlayers', 'fire', 'ads' ]
boundaryServices = [ 'boundaries' ]
allVectorServices = vectorServices
Expand Down Expand Up @@ -258,11 +259,10 @@ module.exports = function ($, app) {
};

this.setTransparency = function (transparency) {
this.transparency = parseFloat(transparency) || this.transparency || 0
if (this.openLayersLayer) {
this.openLayersLayer.setOpacity(1 - parseFloat(transparency)/100.0);
this.openLayersLayer.setOpacity(1.0 - parseFloat(this.transparency)/100.0);
}
this.transparency = transparency;

//Comment this out for now
//Essentially emits the following two commands:
try {
Expand All @@ -273,8 +273,6 @@ module.exports = function ($, app) {
var errTxt = err.Message;
}

// Handle transparency for mask
// Still need to make this parent-layer specific
if (app.map !== undefined) {
var currentLayer, openLayersLayer, lid;
var i;
Expand All @@ -285,7 +283,7 @@ module.exports = function ($, app) {

if (stringContainsChar(currentLayer.name, 'Mask')) {
if (openLayersLayer && (lid.substring(0, lid.indexOf("MaskFor")) === this.lid)) {
openLayersLayer.setOpacity(1 - parseFloat(transparency)/100.0);
openLayersLayer.setOpacity(1 - parseFloat(this.transparency)/100.0);
currentLayer.seldonLayer.transparency = transparency;
}
}
Expand Down
17 changes: 10 additions & 7 deletions js/layer_dialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
// This function gets called every time the layer properties icon gets clicked
module.exports = function ($) {

function updateTransparency (layer, value) {
try {
layer.setTransparency(value);
} catch (e) {
var errTxt = e.message;
}
}

function createLayerPropertiesDialog (layer) {
var localTransparency = 0;
var $html = $(''
Expand Down Expand Up @@ -31,13 +40,7 @@ module.exports = function ($) {
step : 1,
value : localTransparency,
slide : function(event, ui) {
try {
layer.setTransparency(ui.value);
}
catch(err) {
var errTxt = err.message;
// layer.setTransparency($('input.transparency-text').val());
}
updateTransparency(layer, ui.value)
}
});
//This seems redundant as there is already a listener on the slider object
Expand Down
2 changes: 1 addition & 1 deletion js/parse_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ module.exports = function ($) {
if (!layerInThemeOptionsLayers) {
layer.selectedInConfig = true
themeOptions.layers.push(layer);
layer.setTransparency(100 * (1-shareUrlLayerAlpha[layer.lid]));
layer.transparency = 100 * (1-shareUrlLayerAlpha[layer.lid])
}
}
index = index + 1;
Expand Down
3 changes: 2 additions & 1 deletion js/set_mask_by_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.exports = function ($) {
legend : parentLayer.legend,
index : parentLayer.index,
parentLayer : parentLayer,
description : (parentLayer.description ? parentLayer.description : undefined)
description : (parentLayer.description ? parentLayer.description : undefined),
transparency: parentLayer.transparency
});
maskLayer.activate();

Expand Down
7 changes: 4 additions & 3 deletions seldon-min.js

Large diffs are not rendered by default.

34 changes: 18 additions & 16 deletions seldon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,6 @@ module.exports = function ($, app) {
EventEmitter.call(this);
if (!settings) { return; }
$.extend(true, this, settings); // copy all properties from `settings` into `this`
this.transparency = 0;
if (this.index == undefined) {
this.index = 0;
}
Expand Down Expand Up @@ -1438,6 +1437,8 @@ module.exports = function ($, app) {
app.map.addLayer(this.createOpenLayersLayer())
}

this.setTransparency()

vectorServices = [ 'vlayers', 'fire', 'ads' ]
boundaryServices = [ 'boundaries' ]
allVectorServices = vectorServices
Expand Down Expand Up @@ -1554,11 +1555,10 @@ module.exports = function ($, app) {
};

this.setTransparency = function (transparency) {
this.transparency = parseFloat(transparency) || this.transparency || 0
if (this.openLayersLayer) {
this.openLayersLayer.setOpacity(1 - parseFloat(transparency)/100.0);
this.openLayersLayer.setOpacity(1.0 - parseFloat(this.transparency)/100.0);
}
this.transparency = transparency;

//Comment this out for now
//Essentially emits the following two commands:
try {
Expand All @@ -1569,8 +1569,6 @@ module.exports = function ($, app) {
var errTxt = err.Message;
}

// Handle transparency for mask
// Still need to make this parent-layer specific
if (app.map !== undefined) {
var currentLayer, openLayersLayer, lid;
var i;
Expand All @@ -1581,7 +1579,7 @@ module.exports = function ($, app) {

if (stringContainsChar(currentLayer.name, 'Mask')) {
if (openLayersLayer && (lid.substring(0, lid.indexOf("MaskFor")) === this.lid)) {
openLayersLayer.setOpacity(1 - parseFloat(transparency)/100.0);
openLayersLayer.setOpacity(1 - parseFloat(this.transparency)/100.0);
currentLayer.seldonLayer.transparency = transparency;
}
}
Expand Down Expand Up @@ -1629,6 +1627,15 @@ module.exports = function ($) {
},{}],30:[function(require,module,exports){
// This function gets called every time the layer properties icon gets clicked
module.exports = function ($) {

function updateTransparency (layer, value) {
try {
layer.setTransparency(value);
} catch (e) {
var errTxt = e.message;
}
}

function createLayerPropertiesDialog (layer) {
var localTransparency = 0;
var $html = $(''
Expand Down Expand Up @@ -1660,13 +1667,7 @@ module.exports = function ($) {
step : 1,
value : localTransparency,
slide : function(event, ui) {
try {
layer.setTransparency(ui.value);
}
catch(err) {
var errTxt = err.message;
// layer.setTransparency($('input.transparency-text').val());
}
updateTransparency(layer, ui.value)
}
});
//This seems redundant as there is already a listener on the slider object
Expand Down Expand Up @@ -2610,7 +2611,7 @@ module.exports = function ($) {
if (!layerInThemeOptionsLayers) {
layer.selectedInConfig = true
themeOptions.layers.push(layer);
layer.setTransparency(100 * (1-shareUrlLayerAlpha[layer.lid]));
layer.transparency = 100 * (1-shareUrlLayerAlpha[layer.lid])
}
}
index = index + 1;
Expand Down Expand Up @@ -3263,7 +3264,8 @@ module.exports = function ($) {
legend : parentLayer.legend,
index : parentLayer.index,
parentLayer : parentLayer,
description : (parentLayer.description ? parentLayer.description : undefined)
description : (parentLayer.description ? parentLayer.description : undefined),
transparency: parentLayer.transparency
});
maskLayer.activate();

Expand Down

0 comments on commit 7784a0a

Please sign in to comment.