The map and the traffic variables were in the closure of the event callback 
but just in case I'm wrong I modified the script to:
 
google.maps.event.addDomListener( window, 'load', init );
  map = null;
  traffic = null;
        function init() {
            var options = {
                    zoom: 7,
                    center: new google.maps.LatLng( 39.8333333, -98.5833333 
),
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    overviewMapControl: false   // see 
http://code.google.com/apis/maps/documentation/javascript/forum.html?place=topic/google-maps-js-api-v3/YxDUmSzksqs
                };
            map = new google.maps.Map( document.getElementById( "map" ), 
options );
            traffic = new google.maps.TrafficLayer();
            traffic.setMap( window.map );
            google.maps.event.addDomListener(
                document.getElementById( 'b' ),
                'click',
                function() {
                    traffic.setMap( traffic.getMap() === null ? map : null )
                } );
        }
 
Still doesn't work...
 
Val

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