Declare richmondTraffic (and any other KmlLayer) outside of any functions
like where you declare initialLocation, statepolice, etc.

On Mon, May 10, 2010 at 7:06 PM, Jack Berberette <[email protected]> wrote:

> Thanks ESA for the quick response.  The function looks simple enoug but how
> do I set a variable in global scope...ie RichmondTraffic...based on the code
> I have?   Sorry to be such a newb...but I don't want to break what I
> have...lol
>
> I can't thank you enough for helping me out,
>
> Jack
>
>
>
> Sent from my iPhone
>
>
> On May 10, 2010, at 6:25 PM, Esa <[email protected]> wrote:
>
>  Construct a toggle function in global scope
>>
>> function toggleLayer(layer) {
>>   if (layer.getMap()) {
>>     layer.setMap(null);
>>   } else {
>>     layer.setMap(map);
>>   }
>>  }
>>
>> Then you can create buttons like:
>>
>> <button onclick="toggleLayer(RichmondTraffic)"> RichmondTraffic </
>> button>
>>
>> Note that also RichmondTraffic must be a global variable when called
>> by a html button.
>>
>> --
>> 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]<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