Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Api V3 - Change map div

I wanted to ask if anyone knows how to move map from one div to another. Why you would ask... let's say i created complex map, with many tools, letting user to add markers, lines, polygones, save the map position, add infowindows and much more. I am using one div to show the map - all objects are downloaded from database, and put on the map. Then when i press the "change map" button, i get the popup (yeah, that's what i want, i don't want new window) and there is the same map, but with tools which let you to edit it. The problem is, i am atm using same div id, and i am afraid there is some conflict, as my tools are working till i wont refresh map. I am afraid that its because the map below popup is still somehow active, and these functions i am using on the popup map, are used on both? And messing things up?

Or is there a way, to close the map completely, lets say i got a div with a map, and after pushing the button, the map disappears/is closed and i see the div it was in?

I've tried messing around 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 gone/inactive/not used. using same line, just changing div, will create map in both dives, and all functions are made on second map created, so that not a solution.

like image 692
Kedor Avatar asked Nov 10 '11 00:11

Kedor


People also ask

How do I change the map in Google Maps API?

You modify the map type in use by the Map by setting its mapTypeId property, either within the constructor via setting its Map options object, or by calling the map's setMapTypeId() method. The mapTypeID property defaults to roadmap . };

Can you style Google Maps API?

With style options you can customize the presentation of the standard Google map styles, changing the visual display of features like roads, parks, businesses, and other points of interest. As well as changing the style of these features, you can hide features entirely.


1 Answers

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

like image 197
Tomik Avatar answered Sep 25 '22 16:09

Tomik