Files
openlayers/rendering/cases/reproj-tile-disable-smoothing/main.js
mike-000 560931e976 Set reprojection canvas context options
Add example of disabling image smoothing

Add test for reprojection context options
2019-12-20 11:41:42 +00:00

40 lines
950 B
JavaScript

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();