use anchor for offsetting

This commit is contained in:
jkonieczny
2019-12-16 23:24:31 +01:00
committed by Andreas Hocevar
parent 601bd7bae6
commit 1506e13b60
2 changed files with 6 additions and 5 deletions

View File

@@ -13,16 +13,17 @@ const vectorSource = new VectorSource();
function createFeatures(stroke, fill, offSet = [0, 0]) {
let feature;
feature = new Feature({
geometry: new Point([-15 + offSet[0], 15 + offSet[1]])
geometry: new Point([offSet[0], offSet[1]])
});
// square
// square with offset
feature.setStyle(new Style({
image: new RegularShape({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
angle: Math.PI / 4
angle: Math.PI / 4,
offset: [-15, 15]
})
}));
vectorSource.addFeature(feature);