Closed pelord closed 1 year ago
Here the function I try to read.
export function pointerPositionSummaryMarker(feature: olFeature<OlGeometry>, resolution: number): olstyle.Style {
return new olstyle.Style({
image: new olstyle.Icon({
src: './assets/igo2/geo/icons/cross_black_18px.svg',
imgSize: [18, 18], // for ie
}),
text: new olstyle.Text({
text: feature.get('pointerSummary'),
textAlign: 'left',
textBaseline: 'bottom',
font: '12px Calibri,sans-serif',
fill: new olstyle.Fill({ color: '#000' }),
backgroundFill: new olstyle.Fill({ color: 'rgba(255, 255, 255, 0.5)' }),
backgroundStroke: new olstyle.Stroke({ color: 'rgba(200, 200, 200, 0.75)', width: 2 }),
stroke: new olstyle.Stroke({ color: '#fff', width: 3 }),
overflow: true,
offsetX: 10,
offsetY: -10,
padding: [2.5, 2.5, 2.5, 2.5]
})
});
}
Unfortunately it is not possible to translate an ol style function into an geostyler-style as these stylefunctions can contain every possible javascript code.
In your special case you don't make use of the passed in properties olFeature
or resolution
, so you could – if possible in your codebase – just use the returned olstyle.Style
.
If your are commited to stylefunctions you could try to call your function like this and pass the result to the geostyler:
const style = pointerPositionSummaryMarker();
olStyleParser.readStyle(style);
In my case, I use text: feature.get('pointerSummary') to retrieve the feature's text.
Thanks for the quick reply. One more question, how to handle labels based on an attribute with geostyler?
@KaiVolland
How to use this example with geostyler?
https://openlayers.org/en/latest/examples/street-labels.html
Oh sorry. I missed the used feature.
You can use {{propertyname}}
in the textsymbolizer.
Thanks!
Question
It's my first attempt with geostyler. I have a project, running on ol7.2+ and I try to integrate your lib into mine. Into the project, I frequently use stylefunction... I've tried without success to read an ol stylefunction.
In your code, here what I've found
Here the question. How to convert Openlayers's style function into a geostyler style?