Accept an object literal for static layer styling

This commit is contained in:
Tim Schaub
2022-07-28 18:13:13 -06:00
parent d5086a7ab5
commit ab48290bd7
22 changed files with 705 additions and 174 deletions

View File

@@ -1,7 +1,6 @@
import Feature from '../src/ol/Feature.js';
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import {Fill, Icon, Stroke, Style} from '../src/ol/style.js';
import {LineString, Point, Polygon} from '../src/ol/geom.js';
import {
Pointer as PointerInteraction,
@@ -147,22 +146,16 @@ const map = new Map({
source: new VectorSource({
features: [pointFeature, lineFeature, polygonFeature],
}),
style: new Style({
image: new Icon({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.95,
src: 'data/icon.png',
}),
stroke: new Stroke({
width: 3,
color: [255, 0, 0, 1],
}),
fill: new Fill({
color: [0, 0, 255, 0.6],
}),
}),
style: {
'icon-src': 'data/icon.png',
'icon-opacity': 0.95,
'icon-anchor': [0.5, 46],
'icon-anchor-x-units': 'fraction',
'icon-anchor-y-units': 'pixels',
'stroke-width': 3,
'stroke-color': [255, 0, 0, 1],
'fill-color': [0, 0, 255, 0.6],
},
}),
],
target: 'map',