Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
Legend in openlayers with HTML tag

I'm using the following code to create the legends in Openlayers http://viglino.github.io/ol-ext/examples/legend/map.control.legendstat.html.

A question, I would like to insert html tag, for example, the link to a page. It's possible?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You can inspect the code of the example on the site. You will see the following

legend.addItem({ title:'2.600.000', properties: { pop: 2600000 }, typeGeom: 'Point'});

The added row's fire a select event, so you could add a title and your href link to the properties and open that link on select.

Here is a better example of this component: https://viglino.github.io/ol-ext/examples/legend/map.control.legend.html

EDIT:

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);
        
    });
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda