views:

1579

answers:

2

I've got some Javascript/HTML code which displays a variable number of maps dependent on what the user selects.

I've worked how to dynamically create multiple maps on a page - that's well documented.

However, what I'm not so sure on is... how can I safely destroy a map after it's been created - normally I just leave this to GUnload() to sort out.

Thanks for any help!

A: 

Normally You should just leave this to GUnload() to sort out :)

Salman A
Unfortunately, you cannot use GUnload() to unload a single map.
Daniel Vassallo
+1  A: 

Unfortunately the Google Maps API does not yet provide a documented method to GUnload() a single map.

There is an open Issue #772 for this feature on the Google Maps API Issue Tracker. On May 24 2009 it was marked as Acknowledged, but it remains open to this day.

In the first comment of that issue, a Google Maps team member confirmed that a possible "partial" workaround at the moment is to call:

map_to_delete.clearOverlays();
GEvent.clearInstanceListeners(map_to_delete);
Daniel Vassallo