Answer the question
In order to leave comments, you need to log in
How to delete/redraw a Yandex.Map created using the map constructor?
To add a Yandex map to the page, I use js to generate and embed the script tag received in the map constructor into the div container. This trick was required because:
1. I did not find a way to create a map built in the constructor on the page through the Maps Javascript API.
2. The map assembled in the constructor should have a height, while I would like it to take the height from the height of the parent container.
Now I use the resize event so that when the display orientation on the smartphone changes, the map retains the size of the parent container. On this event, I first delete the contents of the container, and then re-add the script tag generated by the map designer to it. Obviously, this is the wrong way to redraw the map, because errors are pouring into the console related to the unexpected removal of the html layout of the map.
Error examples:
Script element was removed from document.
Uncaught TypeError: Cannot read property 'options' of undefined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question