function updateMap for Google Maps API

I’m having issues with the updateMap function in the google Maps API… specifically with using multiple “else if” statements to query data. My code is below. The first “if” works, the first “else if” works, and the last “else” works to update my map, it’s the second “else if” that won’t update my map. The user passes the values for ‘Type’ and ‘Visibilit2’ through drop down menus.

Any suggestions to fix this? The map needs to update based on user values from either, both, or neither by setting the dropdown menu to blank (which is what the last else accounts for). Ideally I would like to expand this to include three or four additional options to query by. The data is stored in a Fusion Table.

google.maps.event.addDomListener(document.getElementById('Type'), 'change', function(){updateMap(layer, tableID, locationColumn);});
google.maps.event.addDomListener(document.getElementById('Visibilit2'), 'change', function(){updateMap(layer, tableID, locationColumn);});

function updateMap(layer, tableID, locationColumn){
    var Type = document.getElementById('Type').value;
    var Visibilit2 = document.getElementById('Visibilit2').value
    if (Type, Visibilit2){
        layer.setOptions({
            query: {
                select: locationColumn,
                from: tableID,
                where: "Type = '" + Type + "' AND Visibilit2 = '" + Visibilit2 + "'"
            }
        });
    } else if (Type){
        layer.setOptions({
            query: {
                select: locationColumn,
                from: tableID,
                where: "Type = '" + Type + "'"
            }
        });
    } else if (Visibilit2){
        layer.setOptions({
            query: {
                select: locationColumn,
                from: tableID,
                where: "Visibilit2 = '" + Visibilit2 + "'"
            }
        });
    }
    else {
        layer.setOptions({
            query: {
                select: locationColumn,

Leave a Comment