Google Maps API Fusion Tables Checkboxes


	
var layer = new google.maps.FusionTablesLayer(); filterMap(layer, tableId, map); google.maps.event.addDomListener(document.getElementById('14'),'click', function() {filterMap(layer, tableId, map);}); google.maps.event.addDomListener(document.getElementById( '9'),'click', function() {filterMap(layer, tableId, map);}); google.maps.event.addDomListener(document.getElementById('10'),'click', function() {filterMap(layer, tableId, map);}); } function filterMap(layer, tableId, map) { var where = generaDove(); if (where) { if (!layer.getMap()) { layer.setMap(map); } layer.setOptions({ query: { select:'Selettore', from: tableId, where: where } }); } else {layer.setMap(null);} } function generaDove() { var filter = []; var seletts = document.getElementsByName('selett'); for (var i = 0, selett; selett = seletts[i]; i++) { if (selett.checked) { var selettName = selett.value.replace(/'/g, '\\\''); filter.push("'" + selettName + "'"); } } var where = ''; if (filter.length) { where = "'Selettore' IN (" + filter.join(',') + ')'; } return where; } google.maps.event.addDomListener(window, 'load', initialize);
Created by