[OpenLayers-Users] How to dim or darken the map

Wagner, Jeffrey S. (Mission Systems) j.wagner at ngc.com
Fri Aug 1 16:41:22 EDT 2008


How can you dim or darken the map using a client side control?  I've
attempted to create a filter div on top of the map div with a black
background that can be darkened by changing the opacity.  This works
well.  However, when the filter div is displayed, I lose the ability to
control the map (e.g. pan, zoom, etc -- because filter has a greater
zIndex then div).
I setup an opacity control that goes from 0 to 2.  Anything greater than
1 will darken the map.
map = new OpenLayers.Map(document.getElementById("map"), { controls: []
});
function changeOpacity(byOpacity) {
	var newOpacity =
(parseFloat(OpenLayers.Util.getElement('opacityInput').value) +
byOpacity).toFixed(1);
	newOpacity = Math.min(maxOpacity, Math.max(minOpacity,
newOpacity));
	OpenLayers.Util.getElement('opacityInput').value =
newOpacity.toFixed(1);
	if(newOpacity <=1){
		document.getElementById("filter").style.display="none";
		map.baseLayer.setOpacity(newOpacity);
	}else{
		document.getElementById("filter").style.display="block";

		var dim = newOpacity-1;
		document.getElementById("filter").style.opacity=dim;
	
document.getElementById("filter").style.backgroundColor="black";	
	}
}



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080801/41592b17/attachment.html


More information about the Users mailing list