mardi 26 mai 2015

checkbox to toggle kml overlays

I cannot figure out why this isnt working... The ID of the checkboxes is the same as the KML overlays that are defined before. The console.log with temporary variable outputs the correct name. But chrome console keeps telling me temp.setMap is not a function. When i fill in the name from the console.log everything works correct. Problem is that we have about 40 checkboxes and we dont want to make an function for each checkbox.

$(function() {
  $(":checkbox").change(function(){
    if ($(this).is(':checked')) {
        var temp = this.id;
        console.log(temp);
        temp.setMap(map);
    } else{
        temp.setMap(null);
    }
  });    
});




Aucun commentaire:

Enregistrer un commentaire