I’ve got an unlisted Fusion Table with sample election data and vote counts by Wisconsin county, and I’m building a maps display page for election night. I’d like to conditionally style the county polygons depending on which candidate has a higher vote count, but I can’t seem to do any styling based on a WHERE clause which directly compares column values. Instead, the default styling takes effect and the where clauses never kick in.
My reading of the FT “SQL-ish” syntax makes me think that it doesn’t allow a WHERE clause which directly compares two columns, so maybe that’s what’s stopping me … but man, I’d very much like to. Is there a technique I’m missing?
Vote counts for candidate 1 are in “1_Vote_Count” and for candidate 2 in “2_Vote_Count”.
<script type="text/javascript">
function initialize () {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(44.824708,-89.780273),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
mapTypeControl: false,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
panControl: false,
});
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'geometry',
from: '173CovMDpzEwyBBtF2fwkxHB5nt6zETzBzG-3YLE',
where: "Office_ID = 'G' AND FIPS_Code > 0"
},
styles: [{
polygonOptions: {
fillColor: "#00FF00",
fillOpacity: 0.3,
strokeWeight: 0.5
}
}, {
where: "'1_Vote_Count' < '2_Vote_Count'",
polygonOptions: {
fillColor: "#DD0000"
}
}, {
where: "'2_Vote_Count' < '1_Vote_Count'",
polygonOptions: {
fillColor: "#0000DD"
}
}]
});
layer.setMap(map);
}
</script>
There’s no technique that you’re missing. I recommend opening a feature request, as Eric noted.
http://code.google.com/p/fusion-tables/issues/list?q=Type%3DFeature_Request