I am using a Fusion Layer to display markers in a google map.
I want to use buttons that will hide specific marker types on the map. For example, a red button that will only hide the red markers and a green button that will only hide the green markers.
I currently have 4 marker types and they are styled by buckets that take data from a "type" column.
I have tried displaying each marker type in its own layer and just hiding the layers individually. Unfortunately google only allows you to style one fusion layer, so I can only use one layer to display the different marker types.
If I could just figure out how to target the markers based on the "type" column, then I could hide specific markers.
Does anyone know how to do that?
My code:
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(37.24,-121.9000);
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: myLatlng,
zoom: 11
});
var FMlayer = new google.maps.FusionTablesLayer({
query: {
select: 'Location',
from: '1zJo4YLRM5VVI_djqSV229FMNFyeGaHGrcczQMSHR',
},
templateId: 3,
styles: [{
where: 'Type = 1',
markerOptions: {
iconName: 'large_green'
}
},{
where: 'Type = 2',
markerOptions: {
iconName: 'large_red'
}
},{
where: 'Type = 3',
markerOptions: {
iconName: 'large_yellow'
}
},{
where: 'Type = 4',
markerOptions: {
iconName: 'large_blue'
}
}],
map: map,
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
My table looks something like this:
Type | Name | Location | Phone
1 | Name1 | Address1 | 555-555-5550
1 | Name2 | Address2 | 555-555-5551
2 | Name3 | Address3 | 555-555-5552
2 | Name4 | Address4 | 555-555-5553
3 | Name5 | Address5 | 555-555-5554
4 | Name6 | Address6 | 555-555-5555
The marker "Type" determines the style of the marker.