I have a map that is displaying two fusion table layers. I have styled them both using the styleId attribute to take the styles defined in the Fusion Table UI instead of using the styles attribute when creating the layer in Google maps. From the maps docs, it mentions that you can have up to 5 fusion table layers, with one of them being styled.
Styles can only be applied to a single Fusion Tables layer per map. You may apply up to five styles to that layer.
What I'm not 100% clear on is if this applies to inline styles only, e.g.:
layer1 = new google.maps.FusionTablesLayer({
query: {
from: table1Id
},
styles: [
{markerOptions: {iconName: 'red_blank'}, where: 'age > 50'},
{markerOptions: {iconName: 'grn_blank'}, where: 'age <= 50'}
]
});
layer2 = new google.maps.FusionTablesLayer({
query: {
from: table2Id
},
styles: [ // This won't work because you can only style one table inline
{markerOptions: {iconName: 'red_blank'}, where: 'age > 50'},
{markerOptions: {iconName: 'grn_blank'}, where: 'age <= 50'}
]
});
or if it also applies to styles defined in the fusion table UI:
layer1 = new google.maps.FusionTablesLayer({
query: {
from: table1Id
},
options: {
styleId: 2, // Obtained from the fusion table UI
templateId: 1 // Obtained from the fusion table UI
}
})
layer2 = new google.maps.FusionTablesLayer({
query: {
from: table2Id
},
options: {
styleId: 2, // Obtained from the fusion table UI
templateId: 1 // Obtained from the fusion table UI
}
})
From my reading of the docs, it would seem that it's only the first type that is not allowed on multiple layers.
The styleId way of styling a table is actually not mentioned in the Google Maps docs, but this is the way the embed code generated in Fusion Tables when you "Publish" a map looks like, and it actually works for individual layers.
If I enable both layers (layer1.setMap(map)), only one of the layers gets displayed. If I disable a layer, the other one appears correctly.
Any help will be greatly appreciated.
"layer"for both layers? variable-names may not be shared, 1 layer will overwrite the other layer. - Dr.Molle