Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Andre' Jones
Andre' Jones
26,671 Points

JavaScript Experts

when i click layer on my google map i need it to disappear. can anyone tell me why this is not working

var map, layer, layer2, that;

function initialize() {
  var magnolia = new google.maps.LatLng(33.2669, -93.2392);

  map = new google.maps.Map(document.getElementById('map-canvas'), {
    center: magnolia,
    zoom: 9,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

  layer = new google.maps.FusionTablesLayer({
    query: {
      select: 'geometry',
      from: '1ShXo1UPsbHgxpCJ_-pgya17THKpAQ8fxGZgYhf0'
    }
  });

  layer.setMap(map);

  layer2 = new google.maps.FusionTablesLayer({
    query: {
      select: 'geometry',
      from: '1_xr2OA7Dch2kIWpPu3Y8m9SbHUYhXuFRVVeNM-o'
    }
  });

  layer2.setMap(map);

  google.maps.event.addListener(layer,'click',function() {
    document.getElementById('that').display = "none";

}); }

google.maps.event.addDomListener(window, 'load', initialize);
Andre' Jones
Andre' Jones
26,671 Points

I will be deleting "that" as a variable also

1 Answer

Andre' Jones
Andre' Jones
26,671 Points

Finally figured it out ended up using jquery

google.maps.event.addListener(layer,'click',function() { $('#that").hide();