fixes #3652 by container opacity approach
This commit is contained in:
parent
91ad43c0cf
commit
5e32cd190c
32
debug/map/tile-opacity.html
Normal file
32
debug/map/tile-opacity.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var map = new L.Map('map');
|
||||
var nexrad = new L.TileLayer.WMS("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
|
||||
layers: 'nexrad-n0r-900913',
|
||||
format: 'image/png',
|
||||
transparent: true,
|
||||
attribution: "Weather data © 2011 IEM Nexrad",
|
||||
opacity: 0.4
|
||||
});
|
||||
|
||||
var bounds = new L.LatLngBounds(new L.LatLng(32, -126), new L.LatLng(50, -64));
|
||||
|
||||
map.addLayer(nexrad).fitBounds(bounds);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -156,14 +156,14 @@ L.GridLayer = L.Layer.extend({
|
||||
|
||||
_updateOpacity: function () {
|
||||
if (!this._map) { return; }
|
||||
var opacity = this.options.opacity;
|
||||
|
||||
// IE doesn't inherit filter opacity properly, so we're forced to set it on tiles
|
||||
if (!L.Browser.ielt9 && !this._map._fadeAnimated) {
|
||||
L.DomUtil.setOpacity(this._container, opacity);
|
||||
if (L.Browser.ielt9 || !this._map._fadeAnimated) {
|
||||
return;
|
||||
}
|
||||
|
||||
L.DomUtil.setOpacity(this._container, this.options.opacity);
|
||||
|
||||
var now = +new Date(),
|
||||
nextFrame = false,
|
||||
willPrune = false;
|
||||
@ -173,11 +173,11 @@ L.GridLayer = L.Layer.extend({
|
||||
if (!tile.current || !tile.loaded) { continue; }
|
||||
|
||||
var fade = Math.min(1, (now - tile.loaded) / 200);
|
||||
|
||||
L.DomUtil.setOpacity(tile.el, fade);
|
||||
if (fade < 1) {
|
||||
L.DomUtil.setOpacity(tile.el, opacity * fade);
|
||||
nextFrame = true;
|
||||
} else {
|
||||
L.DomUtil.setOpacity(tile.el, opacity);
|
||||
if (tile.active) { willPrune = true; }
|
||||
tile.active = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user