LabelLayer how to tell when drawing is finished

المشرف العام

Administrator
طاقم الإدارة
I have a map with a LabelLayer. The label layer is shown and hidden with a checkbox on the page and I have some css classes that I need to dynamically add to the labels based on some criteria. This all works fine, until I zoom my map. When I zoom, but labels are removed and new labels are added which don't have the css classes I need. So what I need to do is know when the map has been zoomed so I can select the nodes that make up my labels and apply the css classes as needed. I though I could do this using map.on('zoom-end', function() { ... }) but it seems that event is getting fired before the label layer has been updated. The available events on the LabelLayer itself seem to not include anything like a zoom-end. I tried graphic-draw, but gets called for every single label, so I ended up with something like this:

var to = null;layerLabel.on("graphic-draw", function () { if (someCondition) { clearTimeout(to); to = setTimeout(function () { // add my classes as needed... }, 10); }});Which is pretty ugly. There has to be a better way right?



أكثر...
 
أعلى