Closed JPelda closed 3 years ago
Hi, you can listen to a visible event on the layer itself. Something along the lines of:
myLayer.on('change:visible', function(e) {
var lyr = e.target;
console.log(lyr.get('title'), lyr.getVisible());
});
Best idea! Thank you very much. Was now able to add a legend to the map that is even movable (done with css and javascript).
Hi, Thank you very much for your work so far! It is really useful! However, I have the following question:
I like to have a click event when a radio button is clicked on the sidebar. Tried to add a customize id or name to it but it does not work.
var myLayer = new VectorLayer({ source: source, style: myStyle, title: "MyTitle", type: 'base', id: 123, });
And finally:
var Group = new LayerGroup({ 'title': 'Max Title', 'fold': 'open', layers: [myLayer] });
But I can not access the radio button via document.getElementById(123). The id/name is also not shown in the statement in the sidebar.
Any ideas/help? THX!