Fix icon displacement
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.1 KiB |
@@ -8,6 +8,7 @@ import Style from '../../../src/ol/style/Style.js';
|
||||
import VectorLayer from '../../../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../../../src/ol/source/Vector.js';
|
||||
import View from '../../../src/ol/View.js';
|
||||
import {Icon} from '../../../src/ol/style.js';
|
||||
|
||||
const vectorSource = new VectorSource();
|
||||
function createFeatures(stroke, fill, offSet = [0, 0]) {
|
||||
@@ -16,7 +17,7 @@ function createFeatures(stroke, fill, offSet = [0, 0]) {
|
||||
geometry: new Point([offSet[0], offSet[1]]),
|
||||
});
|
||||
// square with offset
|
||||
feature.setStyle(
|
||||
feature.setStyle([
|
||||
new Style({
|
||||
image: new RegularShape({
|
||||
fill: fill,
|
||||
@@ -26,8 +27,18 @@ function createFeatures(stroke, fill, offSet = [0, 0]) {
|
||||
angle: Math.PI / 4,
|
||||
displacement: [-15, 15],
|
||||
}),
|
||||
})
|
||||
);
|
||||
}),
|
||||
new Style({
|
||||
image: new Icon({
|
||||
src: '/data/cross.svg',
|
||||
size: [20, 20],
|
||||
anchor: [0.5, 0.5],
|
||||
anchorXUnits: 'fraction',
|
||||
anchorYUnits: 'fraction',
|
||||
displacement: [-15, 15],
|
||||
}),
|
||||
}),
|
||||
]);
|
||||
vectorSource.addFeature(feature);
|
||||
|
||||
feature = new Feature({
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="20" height="20" viewBox="0 0 580 581" version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
|
||||
xmlns:serif="http://www.serif.com/">
|
||||
<path d="M506.409,236.125L344.102,236.125L344.102,73.819L235.896,73.819L235.896,236.125L73.588,236.125L73.588,344.331L235.896,344.331L235.896,506.639L344.102,506.639L344.102,344.331L506.409,344.331L506.409,236.125Z" style="fill:rgb(8,129,32);"/>
|
||||
<path d="M579.997,0L0,0L0,580.457L579.997,580.457L579.997,0ZM549.997,30L549.997,550.457C549.997,550.457 30,550.457 30,550.457C30,550.457 30,30 30,30C30,30 549.997,30 549.997,30L549.997,30Z" style="fill:rgb(8,129,32);"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 847 B |
Reference in New Issue
Block a user