As one option, you can create SVG elements with the same attributes as in OL3 style. Here is an example for a circle style (you will need similar methods and other types):
getIconLegend = function(style) { style = style.getImage(); var radius = style.getRadius(); var strokeWidth = style.getStroke().getWidth(); var dx = radius + strokeWidth; var svgElem = $('<svg />') .attr({ width: dx * 2, height: dx * 2 }); $('<circle />') .attr({ cx: dx, cy: dx, r: radius, stroke: style.getStroke().getColor(), 'stroke-width': strokeWidth, fill: style.getFill().getColor() }) .appendTo(svgElem);
Since manipulating SVG with jQuery is slightly different from HTML elements, I convert the object to a string in response. Details can be found from the app jquery does not work with svg element
You can later insert the legend icon in HTML using
$('#legendText').prepend($(getIconLegend(yourFeature.getStyle())));
source share