Hi Chad, Thanks for the tips! I ended up using the second solution, and setting the CSS of the div to display=none upon creation of the control. Works fine!
Thanks for your quick answer! On Jun 21, 2:22 pm, Chad Killingsworth <[email protected]> wrote: > Controls are not added to the map (and thus the page DOM) until later > in the map initialization. If you try to hide them before they are > added, then the behavior you mention would be expected. > > 1) Don't add them to the map until you are ready to use them. > 2) Hide them with css initially. > > Chad Killingsworth > > On Jun 21, 2:51 am, KnutMarius <[email protected]> wrote: > > > > > I have just started upgrading my application from Google maps v2 to > > v3, and I have a question regarding the new way to handle custom map > > controls: > > > At application start-up I first create a couple of custom controls and > > attach them to the map. I then call the jQuery method $ > > ("#myControlDiv").hide() in order to hide them (They will be activated > > later). This does not seem to work properly, however. The controls are > > all visible at application startup. I have put a breakpoint at the > > call to hide(), and it seems that jQuery cannot find a div with that > > ID at that point in time. In v2 I used map.removeControl(..) and > > map.addControl(..) instead of the jquery show/hide, but as far as I > > could read from the API this approach was not possible anymore. > > > Also, when I try to show() and hide() the controls _later_ in the > > application it works fine! Does anyone know if there is a better way > > of disabling/enabling custom controls, or if there is a simple fix I > > can apply to the code I have now? It seems to me that the actual div- > > element is created after I try to hide it, even though > > document.createElement(..) is called before I run hide(). -- 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.
