On Apr 27, 9:41 am, Val <
val.mela...@gmail.com> wrote:
> Hello,
>
> For now I am just playing with the google maps and the traffic layer. I
> would like to have a button which toggles the traffic layer. I figuered that
> code as simple as:
>
> > traffic.setMap( traffic.getMap() != null ? null : map );
>
> should do the trick but apparently I am doing something wrong. It works only
> on the first click - removes the traffic and then I can no longer show it
> back again.
>
> Please, help me with this.
>
> Thank you!
> Val
>
> P.S.
> but sooner or later I'll remove it, therefore I am also copying the code below:
>
> > <!DOCTYPE html><html><head>
> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> > <title>Toggle Traffic</title>
> > <style type="text/css">
> > html { height: 100%;}
> > body { height: 100%; margin: 0px; padding: 0px; }
> > #map { height: 600px; width: 600px; }
> > </style></head><body>
> > <button id="b" type="button">
> > ToggleTraffic</button>
> > <div id="map" class="map">
> > </div>
> > <script src="
http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
> > <script type="text/javascript">
> > google.maps.event.addDomListener( window, 'load', init );
>
> > function init() {
> > var options = {
> > zoom: 7,
> > center: new google.maps.LatLng( 39.8333333, -98.5833333 ),
> > mapTypeId: google.maps.MapTypeId.ROADMAP,