There is a map where the polygon is displayed, points, routes. Everything is added via myMap.geoObjects.add(); And there are tabs that switch one or another view (points, marurts, etc.). To change these views, I delete everything through myMap.geoObjects.removeAll(); and re-generate what I need. It is necessary that when switching tabs, everything was deleted, except for the polygon.
|
1 answer
When changing a tab, you can delete not all objects, but only those that were created on it and are no longer needed. The remove() method is available for this.
Another option is to re-add the polygon after each removeAll() , but it is better to remove only the extra ones.
- Well, I add again and it seems to be a small blink, I would like to get rid of it, well, and what should I write if I just use remove (). , but what? - Karalahti
- delete only unnecessary objects more correctly. There in the answer is a link to the documentation - you need to transfer the same name of the object as indicated in add. - Reni
- Super, earned. Thank you - Karalahti
|