Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!