Files
openlayers/test/spec/ol/renderer/canvas/imagelayer.test.js
Tim Schaub ad62739a6e Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
2018-01-12 00:50:30 -07:00

66 lines
1.7 KiB
JavaScript

import Map from '../../../../../src/ol/Map.js';
import View from '../../../../../src/ol/View.js';
import ImageLayer from '../../../../../src/ol/layer/Image.js';
import Projection from '../../../../../src/ol/proj/Projection.js';
import Static from '../../../../../src/ol/source/ImageStatic.js';
describe('ol.renderer.canvas.ImageLayer', function() {
describe('#forEachLayerAtCoordinate', function() {
let map, target, source;
beforeEach(function(done) {
const projection = new Projection({
code: 'custom-image',
units: 'pixels',
extent: [0, 0, 200, 200]
});
target = document.createElement('div');
target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target);
source = new Static({
url: 'spec/ol/data/dot.png',
projection: projection,
imageExtent: [0, 0, 20, 20]
});
map = new Map({
pixelRatio: 1,
target: target,
layers: [new ImageLayer({
source: source
})],
view: new View({
projection: projection,
center: [10, 10],
zoom: 2,
maxZoom: 8
})
});
source.on('imageloadend', function() {
done();
});
});
afterEach(function() {
map.setTarget(null);
document.body.removeChild(target);
});
it('properly detects pixels', function() {
map.renderSync();
let has = false;
function hasLayer() {
has = true;
}
map.forEachLayerAtPixel([20, 80], hasLayer);
expect(has).to.be(true);
has = false;
map.forEachLayerAtPixel([10, 90], hasLayer);
expect(has).to.be(false);
});
});
});