Set reprojection canvas context options
Add example of disabling image smoothing Add test for reprojection context options
This commit is contained in:
BIN
rendering/cases/reproj-tile-disable-smoothing/expected.png
Normal file
BIN
rendering/cases/reproj-tile-disable-smoothing/expected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
39
rendering/cases/reproj-tile-disable-smoothing/main.js
Normal file
39
rendering/cases/reproj-tile-disable-smoothing/main.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import Map from '../../../src/ol/Map.js';
|
||||
import View from '../../../src/ol/View.js';
|
||||
import XYZ from '../../../src/ol/source/XYZ.js';
|
||||
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||
import {toLonLat} from '../../../src/ol/proj.js';
|
||||
import {createXYZ} from '../../../src/ol/tilegrid.js';
|
||||
|
||||
const tileGrid = createXYZ();
|
||||
const extent = tileGrid.getTileCoordExtent([5, 5, 12]);
|
||||
const center = [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
|
||||
|
||||
const source = new XYZ({
|
||||
transition: 0,
|
||||
minZoom: 5,
|
||||
maxZoom: 5,
|
||||
reprojectionContextOptions: {imageSmoothingEnabled: false},
|
||||
url: '/data/tiles/osm/{z}/{x}/{y}.png'
|
||||
});
|
||||
|
||||
const layer = new TileLayer({
|
||||
source: source
|
||||
});
|
||||
|
||||
layer.on('prerender', function(evt) {
|
||||
evt.context.imageSmoothingEnabled = false;
|
||||
});
|
||||
|
||||
new Map({
|
||||
pixelRatio: 1,
|
||||
target: 'map',
|
||||
layers: [layer],
|
||||
view: new View({
|
||||
projection: 'EPSG:4326',
|
||||
center: toLonLat(center),
|
||||
zoom: 10
|
||||
})
|
||||
});
|
||||
|
||||
render();
|
||||
Reference in New Issue
Block a user