Nice catch Chad, I just got down to the part where the scope was the issue
and stopped there.

On Mon, Jul 12, 2010 at 11:41 AM, Chad Killingsworth <
[email protected]> wrote:

> Scope is only part of the issue I believe.
>
> ctaLayer = new google.maps.KmlLayer('http://www.mappingsupport.com/p/
> gmap4/mymap/05/105432215366276592381.0004897737811ac6a6a05.kml?
> dummy=12345678', {preserveViewport:false, map:masu.map});
> ctaLayer.setMap(masu.map);
>
> Here the call to setMap is redundant - you declared it as part of the
> map options.
>
> Also, in your toggle_kml function, you don't need to keep track of the
> state of the layer separately. You also should be able to get rid of
> your bounds_changed event listener. Try:
>
> var ctaLayer;
> function toggle_kml() {
>    if(ctaLayer.getMap()) {
>        ctaLayer.setMap(null);
>        ctaLayer.set('preserveViewport', false);
>    }
>    else
>        ctaLayer.setMap(masu.map);
> }
>
> Chad Killingsworth
>
> On Jul 12, 11:30 am, Nathan Raley <[email protected]> wrote:
> > It looks like a scoping issue.
> >
> > ctaLayer is declared inside the initialize function and therefore is not
> > accessible to the rest of your code.
> >
> > Declare ctaLayer as a global variable and you should be okay.
> >
> > On Mon, Jul 12, 2010 at 11:24 AM, Joseph Elfelt <[email protected]
> >wrote:
> >
> >
> >
> > > The KML toggle control on this map works fine.
> > >http://www.mappingsupport.com/forum_post/toggle_kml_good.html
> >
> > > The KML toggle control on this map causes the KML to briefly flicker
> > > and then the KML remains visible.
> > >http://www.mappingsupport.com/forum_post/toggle_kml_bad.html
> >
> > > The only difference is in the 'options' in the line defining the
> > > KmlLayer.
> > > KML options for the good map:  {preserveViewport:false}
> > > KML options for the bad map:    {preserveViewport:false, map:masu.map}
> >
> > > --
> > > 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]<google-maps-js-api-v3%[email protected]><google-maps-js-api-v3%2B
> [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> --
> 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]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
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.

Reply via email to