I was trying to have a vector layer(from OL) above Open Street Map (OSM()). I wanted a wind barb layer, for which I used d3-wind-barb from npm. I couldn't use it as style though it throws HTML objects in the console.
layers: [
new TileLayer({
source: new OSM(),
}),
new VectorLayer({
source: vectorSource,
style: function (feature) {
const wind = feature.get("wind");
// using d3 windbarb
var svg = new D3WindBarb(180, 50).draw("#container");
console.log(svg);
var svg_1 =
"data:image/svg+xml;utf8," +
'<svg width="120" height="120" version="1.1" xmlns="http://www.w3.org/2000/svg">' +
'<circle cx="60" cy="60" r="60"/>' +
"</svg>";
console.log(svg_1);
const outVal = new Style({
image: new Icon({
src: svg_1,
// src: svg, to be used when svg is set as source
size: 0.1,
}),
});
return outVal;
},
}),
]
In this code when I try using src inside ICON as svg it doesn't work but when I use svg_1 the SVG is shown as a layer. During the console of svg and svg_1 the types are object and string respectively, but in both cases, they contain HTML tags.
How can I solve this problem? Additionally, I would be open to considering alternative methods for displaying wind barbs in OpenLayers.