Colleagues, a few days ago I started working with YandexCards. Not so strong in JavaScript, and in particular with callback functions ... I’d like to be simple)) I have a task to hide the labels (Point) depending on what I need to show. Made a filter for Point in ObjectManager. I turn on the filter, turn it off, everything is fine. Found here an example with a multiple choice in listBoxControl. 3rd example. Made listBoxControl, in it it is a lot of listBoxItems. I left the code up to the line "// Add a change tracking feature, if the list item is selected."

Everything suits, menus open, checkmarks are set, removed ...

Now I need to make my filter. My filter is not like in the example of "pharmacy" and "store", but by ID, where from 0-100 there are some points, from 101 to 750 others, etc. Those. I will form the string with the filter "hands", it is easier for me.

I want to know the status of the checkbox on the listBoxControl (isSelected?) ... but it’s trite to run through the listBoxItems in a loop. I can not find out their number. And therefore each will be addressed. How to implement it?

    1 answer 1

    Hello, friends. By trial and error figured out! Maybe someone else will help. I didn’t like the standard examples from Yandex, in particular with the filter.

    Cycle of yandex maps listBox:

    for (let i = 0; i < listBoxControl.getAll().length; i++) { if (listBoxControl.getAll()[i].isSelected()){ alert(listBoxControl.getAll()[i].data.get('content')); } }