I am coloring country polygon with different colors in a layer depending on different condition. But after the five "where" conditions, it didnt detect the associated color. But uses the default color. Why is this happening? Below is my code:
layer.setOptions({
query: {
select: 'masterNarrative, countryName',
from: tableId,
where: where
},
styles: [{
where: "masterNarrative= '72 virgins (houris)' ",
polygonOptions: {
fillColor: '#2daebf',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Badr' ",
polygonOptions: {
fillColor: '#e33100',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Crusaders/Colonization' ",
polygonOptions: {
fillColor: '#a9014b',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Nakba (Palestine)' ",
polygonOptions: {
fillColor: '#871F78',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Hypocrites (Munafiqun)' ",
polygonOptions: {
fillColor: '#ff5c00',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Mahdi' ",
polygonOptions: {
fillColor: '#ffb515',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Musaylimah' ",
polygonOptions: {
fillColor: '#34925E',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Pharaoh' ",
polygonOptions: {
fillColor: '#E066FF',
fillOpacity: 0.5
}
},
{
where: "masterNarrative= 'Puppet Master' ",
polygonOptions: {
fillColor: '#00FF00',
fillOpacity: 0.5
}
}]
});
I am finding that these fillColors are not coming through when calling the FusionTablesLayer. I am using the bucket technique in Fusion but when I call the map out I am just getting the default markers. I would love to be able to use the function inside Fusion since doing it in javascript seems to be redundant.
As noted in the limits for the FusionTablesLayer: You can use the Maps API to add up to five Fusion Tables layers to a map, one of which can be styled with up to five styling rules.
One way to avoid using your five styling rules on setting colors per "masterNarrative" column would be to use the Fusion Tables UI to set the colors rather than do it in javascript via the FusionTablesLayer. To do this, you can create another column in your table called, for example "fillColor", and set the value for that column to be whatever color you want for the row. Then you can go Visualize -> Map, then Configure Styles, and then Fill Color -> Column to select which column the map should be colored by.
来源:https://stackoverflow.com/questions/11751960/google-fusion-table-not-able-to-color-the-layer-in-map-after-5-colors