We have been running into an occasional problem where we will initalize some type of overlay and attach it to the map using setMap(), but then due to some user event we will be immediately required to destroy it using setMap(null) as documented. It seems if setMap(null) is called too soon after setMap(map) an error will be raised inside of the google maps api in some asyncronous code. The error is a little different between browsers but occurs in all that I have tested. It is usually something like "a is undefined" (firefox), "Uncaught TypeError: Cannot call method 'setPaths' of undefined" (Chrome), or "SCRIPT5007: Unable to get value of the property 'setPaths': object is null or undefined" (IE9). I presume this is occurring because the maps api has queued the drawing of the overlay but hasn't gotten around to doing it until after setMap(null) has already been called.
A simple test fixture with the different versions of the 3.x api is posted at http://www.blurbco.com/~gork/maps/ The fixture is an excercise in writing useless code, but it's enough to demonstrate the problem which seems to be present in all api versions. Oddly, the problem doesn't occur the first time setMap(map); setMap(null); are called in immediate succession, but it happens every time thereafter. I wanted to ask here first to find out if this is actually a bug or not, and if not to solicit an idea on the "proper" way to do this instead. For what we are doing that is triggering this error I can think of several ways we might get around triggering the problem. Also, aside from a workaround, I do not seem to be able to trap the error either. Using try..catch does not work because it occurs asynchronously, but onError trapping doesn't seem to work either -- I presume the API is overriding any handler I assign? Thanks, John -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
