Skip to content Skip to sidebar Skip to footer

Javascript For Google Fusion Table Layers Working But Trying To Tidy Code

I'm creating a map using Google Fusion Tables. It has several layers that are displayed or hidden depending on which checkboxes are ticked. I created some code to turn the layers o

Solution 1:

I showed an example toggleLayer in this answer but it's not that concise. this_layer is the actual FT Layer which should be a global. This checks whether the layer is visible or not.

function toggleLayer(this_layer)
{
   if( this_layer.getMap() ){
        this_layer.setMap(null);
   }else{
        this_layer.setMap(map);
   }
}

You need to have both your map as a global as well as your layers. I think, but have not tested that your checkboxes should look like:

<input value="layer10"id="check10"type="checkbox" checked onchange="toggleLayer(layer10);" />

Post a Comment for "Javascript For Google Fusion Table Layers Working But Trying To Tidy Code"