Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-472: Special handling for visibility of control that acts like layer

Mike McGann7711caf0244d
diff --git a/src/js/Worldview/Map.js b/src/js/Worldview/Map.js
index d3546cfbe..93f6617f3 100644
--- a/src/js/Worldview/Map.js
+++ b/src/js/Worldview/Map.js
@@ -154,10 +154,14 @@ $(function(ns) {
* is visible. A value from 0 (transparent) to 1 (opaque).
*/
ns.setVisibility = function(layer, visible, opacity) {
- var actualOpacity = ( visible ) ? opacity : 0;
- layer.div.style.opacity = actualOpacity;
- if ( visible && opacity > 0 && !layer.getVisibility() ) {
- layer.setVisibility(true);
+ if ( layer.isControl ) {
+ layer.setVisibility(visible);
+ } else {
+ var actualOpacity = ( visible ) ? opacity : 0;
+ layer.div.style.opacity = actualOpacity;
+ if ( visible && opacity > 0 && !layer.getVisibility() ) {
+ layer.setVisibility(true);
+ }
}
};
diff --git a/src/js/Worldview/Map/GraticuleLayer.js b/src/js/Worldview/Map/GraticuleLayer.js
index 64ecabb23..db19fc455 100644
--- a/src/js/Worldview/Map/GraticuleLayer.js
+++ b/src/js/Worldview/Map/GraticuleLayer.js
@@ -20,11 +20,12 @@ Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
graticuleLineStyle: null,
graticuleLabelStyle: null,
graticule: null,
-
+ isControl: true,
+
initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
- graticuleLineStyle = new OpenLayers.Symbolizer.Line({
+ this.graticuleLineStyle = new OpenLayers.Symbolizer.Line({
strokeColor: '#AAAAAA',
strokeOpacity: 0.95,
strokeWidth: 1.35,
@@ -32,7 +33,7 @@ Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
strokeDashstyle: 'dot'
});
- graticuleLabelStyle = new OpenLayers.Symbolizer.Text({
+ this.graticuleLabelStyle = new OpenLayers.Symbolizer.Text({
fontFamily: 'Gill Sans',
fontSize: '16',
fontWeight: '550',
@@ -47,15 +48,15 @@ Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
- graticule = new OpenLayers.Control.Graticule({
+ this.graticule = new OpenLayers.Control.Graticule({
layerName: 'ol_graticule_control',
numPoints: 2,
labelled: true,
- lineSymbolizer: graticuleLineStyle,
- labelSymbolizer: graticuleLabelStyle
+ lineSymbolizer: this.graticuleLineStyle,
+ labelSymbolizer: this.graticuleLabelStyle
});
- map.addControl(graticule);
+ map.addControl(this.graticule);
},
/*
@@ -63,9 +64,17 @@ Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
*/
removeMap: function(map) {
OpenLayers.Layer.prototype.removeMap.apply(this, arguments);
- map.removeControl(graticule);
- graticule.destroy();
- graticule = null;
+ map.removeControl(this.graticule);
+ this.graticule.destroy();
+ this.graticule = null;
+ },
+
+ setVisibility: function(value) {
+ if ( value ) {
+ this.graticule.activate();
+ } else {
+ this.graticule.deactivate();
+ }
},
/*