Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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();