basic GridLayer spec, move TileLayer spec
This commit is contained in:
parent
dd313e6930
commit
04c95e1af9
@ -60,9 +60,12 @@
|
||||
<script type="text/javascript" src="suites/layer/FeatureGroupSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/GeoJSONSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/LayerGroupSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/TileLayerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/PopupSpec.js"></script>
|
||||
|
||||
<!-- /layer/tile -->
|
||||
<script type="text/javascript" src="suites/layer/tile/GridLayerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/tile/TileLayerSpec.js"></script>
|
||||
|
||||
<!-- /layer/marker/ -->
|
||||
<script type="text/javascript" src="suites/layer/marker/MarkerSpec.js"></script>
|
||||
|
||||
|
54
spec/suites/layer/tile/GridLayerSpec.js
Normal file
54
spec/suites/layer/tile/GridLayerSpec.js
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
describe('GridLayer', function () {
|
||||
|
||||
var div;
|
||||
|
||||
beforeEach(function () {
|
||||
div = document.createElement('div');
|
||||
div.style.width = '800px';
|
||||
div.style.height = '600px';
|
||||
div.style.visibility = 'hidden';
|
||||
|
||||
document.body.appendChild(div);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
it('positions tiles correctly with wrapping and bounding', function () {
|
||||
|
||||
var map = L.map(div).setView([0, 0], 1);
|
||||
|
||||
var tiles = [];
|
||||
|
||||
var grid = L.gridLayer();
|
||||
grid.createTile = function (coords) {
|
||||
var tile = document.createElement('div');
|
||||
tiles.push({coords: coords, tile: tile});
|
||||
return tile;
|
||||
};
|
||||
|
||||
map.addLayer(grid);
|
||||
|
||||
var loaded = {};
|
||||
|
||||
for (var i = 0; i < tiles.length; i++) {
|
||||
var coords = tiles[i].coords,
|
||||
pos = L.DomUtil.getPosition(tiles[i].tile);
|
||||
|
||||
loaded[pos.x + ':' + pos.y] = [coords.x, coords.y];
|
||||
}
|
||||
|
||||
expect(loaded).to.eql({
|
||||
'144:44': [0, 0],
|
||||
'400:44': [1, 0],
|
||||
'144:300': [0, 1],
|
||||
'400:300': [1, 1],
|
||||
'-112:44': [1, 0],
|
||||
'656:44': [0, 0],
|
||||
'-112:300': [1, 1],
|
||||
'656:300': [0, 1]
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user