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

Correct TileLayer zIndex behaviour on bringToBack #963

Merged
merged 1 commit into from
Sep 11, 2012
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Correct zIndex behaviour (Previously if you had 2 layers, neither of …
…which had a zindex we'd set the zIndex to 0 on bringToBack and not remember it. On zoom it would revert). Add a test page for tile layer zIndex. Refs #959
  • Loading branch information
danzel committed Aug 30, 2012
commit 21be460719a43969fc709b8560d353cb0516d076
37 changes: 37 additions & 0 deletions debug/tests/bringtoback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<title>Leaflet debug page</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

<link rel="stylesheet" href="../../dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->

<link rel="stylesheet" href="../css/screen.css" />
<script src="../leaflet-include.js"></script>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
</head>
<body>

<div id="map"></div>
<button id="foo">Click to add layer, then zoom out or in</button>

<script type="text/javascript">

var map = new L.Map('map', { center: new L.LatLng(45.50144, -122.67599), zoom: 4 });

var demoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/tile/{z}/{y}/{x}';
var demoMap = new L.TileLayer(demoUrl, { maxZoom: 19, attribution: 'Tiles: &copy; Esri' });

map.addLayer(demoMap);

$('#foo').click(function() {
var topoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}';
var topoMap = new L.TileLayer(topoUrl, { maxZoom: 19, attribution: 'Tiles: &copy; Esri' });
map.addLayer(topoMap);
topoMap.bringToBack();
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/layer/tile/TileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ L.TileLayer = L.Class.extend({
}
}

this._container.style.zIndex = isFinite(edgeZIndex) ? edgeZIndex + compare(1, -1) : '';
this.options.zIndex = this._container.style.zIndex = (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1);
},

_updateOpacity: function () {
Expand Down