Fix sprite offset for pixel ratio !== 1

This commit is contained in:
Andreas Hocevar
2021-08-30 21:53:46 +02:00
parent 706955dfd9
commit df493725c6
5 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
import Feature from '../../../../src/ol/Feature.js';
import Map from '../../../../src/ol/Map.js';
import Point from '../../../../src/ol/geom/Point.js';
import View from '../../../../src/ol/View.js';
import {Icon, Style} from '../../../../src/ol/style.js';
import {Vector as VectorLayer} from '../../../../src/ol/layer.js';
import {Vector as VectorSource} from '../../../../src/ol/source.js';
const center = [0, 0];
new Map({
pixelRatio: 2,
layers: [
new VectorLayer({
style: function () {
return new Style({
image: new Icon({
src: '/data/sprites/gis_symbols.png',
color: [255, 0, 0, 1],
offset: [32, 0],
size: [32, 32],
}),
});
},
source: new VectorSource({
features: [new Feature(new Point(center))],
}),
}),
],
target: 'map',
view: new View({
center: center,
zoom: 2,
}),
});
render();