Google Maps Api V3 - Change map div

I wanted to ask if anyone knows how to move a map from one div to another. Why do you ask ... let's say I created a complex map with many tools, allowing the user to add markers, lines, polygons, save the position of the map, add info windows and much more. I use one div to display the map - all objects are loaded from the database and placed on the map. Then, when I click on the β€œchange map” button, I get a pop-up window (yes, this is what I want, I don't want a new window), and there is the same map, but with tools that allow you to edit his. The problem is that I am using the same div id, and I am afraid that there is some conflict, since my tools work until I update the map. I'm afraid of him, because the card under the pop-up is still somehow active, and are these functions that I use on the pop-up card used on both? And ruin everything?

Or is there a way to completely close the map, say, I have a div with a map, and after clicking the button, the map disappears / closes, and I see the div in which it was located?

I tried communicating with "mapa = new google.maps.Map(document.getElementById("map_div"), mapOptions);

but I just don’t know what to do to make the old div go away / inactive / not used. using the same line, just changing the div will create a map in both dives, and all functions will be created on the second map created so that there is no solution.

+4
source share
1 answer

Moving a map to another div is simple, it's just a matter of managing the DOM tree. See the answer to this question with map cloning .

+4
source

Source: https://habr.com/ru/post/1380486/


All Articles