How about:

MyControl.prototype.initialize = function( map )
{
        this.controlDiv = document.createElement( "div" );
        ...

        var closeButton = document.createElement( "img" );
        ...
        var i=this.controlDiv;
        google.maps.Event.addDomListener( closeButton, "click",
function()
                {
                        i.style.display = "none";
                }
        );

Get the required closure with a local variable.

Martin.


On 25 Nov, 16:54, Anthony <[EMAIL PROTECTED]> wrote:
> I'm developing a custom control for my maps, and I would like to add a
> simple close button (i.e. X) to make the control invisible (i.e. CSS
> display = none). However, I can't seem to get the proper reference to
> the control div element to do this -- everything I've tried gives
> JavaScript errors.
>
> I know this is sort of a JavaScript question, but I'm assuming someone
> has done this before with Google Maps controls.
>
> Here's what I'm trying below (which doesn't work); controlDiv is
> declared as a object member elsewhere, but it's not accessible inside
> the click handler.
>
> MyControl.prototype.initialize = function( map )
> {
>         this.controlDiv = document.createElement( "div" );
>         ...
>
>         var closeButton = document.createElement( "img" );
>         ...
>
>         google.maps.Event.addDomListener( closeButton, "click", function()
>                 {
>                         this.controlDiv.style.display = "none";
>                 }
>         );
>         ...
>
> };
--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to