Estoy usando el siguiente código para crear las leyendas en Openlayers http://viglino.github.io/ol-ext/examples/legend/map.control.legendstat.html .
Una pregunta, me gustaría insertar una etiqueta html, por ejemplo, el enlace a una página. ¿Es posible?
Puede inspeccionar el código del ejemplo en el sitio. Verás lo siguiente
legend.addItem({ title:'2.600.000', properties: { pop: 2600000 }, typeGeom: 'Point'});La fila agregada activa un evento de selección, por lo que puede agregar un título y su enlace href a las propiedades y abrir ese enlace al seleccionar.
Aquí hay un mejor ejemplo de este componente: https://viglino.github.io/ol-ext/examples/legend/map.control.legend.html
EDITAR:
const legend = new ol.legend.Legend({ title: 'Legend', }) const legendCtrl = new ol.control.Legend({ legend: legend, collapsed: false }); legend.addItem({ title: 'Google', properties: {link: 'http://www.google.com'} }); legend.addItem({ title: 'Apple', properties: {link: 'http://www.apple.com'} }); legend.on('select', function(event) { window.open(event.item.get('properties').link); });