On Nov 16, 7:52 pm, Mike Dunham-Wilkie <[email protected]> wrote: > In my applicationhttp://members.shaw.ca/msdwilkieI display a mini > map inside an infowindow. This used to work fine, but last week I > looked at the app again and noticed some strange behaviour. The first > time you click on the marker the infowindow that gets displayed is > empty and a Javascript error occurs. On subsequent clicks everything > works fine. The basic logic is > > var tab1 = new GInfoWindowTab("Info", '<div id="detailmap" > class="bubble"></div>'); > var infoTabs = [tab1]; > marker.openInfoWindowTabsHtml(infoTabs); > ... some more code > dMapDiv = document.getElementById("detailmap"); > detailMap = new GMap2(dMapDiv); > > What's happening is that dMapDiv gets set to null the first time this > code is run (perhaps because the DOM object hasn't had time to be > created yet?), so the last statement (creating the GMap) fails.
It looks to me like your code would never have worked. getElementById can only find elements that exist in the DOM. The element with id="detailmap" isn't added to the DOM until after the infoWindow is rendered, which won't be until after your javascript has returned control to the browser. When I have needed to do something like that, I create a DOM element directly and use that as the argument for GMap2. -- Larry > > I've noticed that this > pagehttp://mappinghacks.com/projects/gmaps/map_in_box.html > exhibits the same behaviour. Presumably it also worked properly at > some point in the past. > > I'm at a loss for how to ensure that the detailmap DOM div object gets > created before it gets referred to. Any help would be greatly > appreciated! > > ...Mike -- You received this message because you are subscribed to the Google Groups "Google Maps API" 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-api?hl=.
