title: How to create a custom layer in google earth so I can set it's visibility
body: <p>I am trying to render a whole heap of vectors in the google earth plugin. I use the parseKml method to create my Kml Feature object and store it in an array. The code looks something like below. I loop over a list of 10,000 kml objects that I return from a database and draw it in the plugin.</p>
  
  <pre><code>// 'currentKml' is a kml string returned from my DB. 
  // I iterate over 10,000 of these
  currentKmlObject = ge.parseKml(currentKml);
  currentKmlObject.setStyleSelector(gex.dom.buildStyle({
      line: { width: 8, color: '7fff0000' }
  }));
  ge.getFeatures().appendChild(currentKmlObject);
  // After this, I store teh currentKml object in an array so 
  // I can manipulate the individual features.
  </code></pre>
  
  <p>This seems to work fine. But when I want to turn the visibility of all these features on or off at once, I have to iterate over all of these kml objects in my array and set their individual visibilities on or off. This is a bit slow. If I am zoomed out, I can slowly see each of the lines disappearing and it takes about 5 - 10 seconds for all of them to disappear or come back.</p>
  
  <p>I was wondering if I could speed up this process by adding a layer and adding all my objects as children of this layer. This way I set the visibility of the whole layer on or off.</p>
  
  <p>I have been unable to find out how to create a new layer in code though. If someone can point the appropriate methods, it would be great. I am not sure if a layer is the right approach to speed up the process either. If you also have any other suggestions on how I can speed up the process of turning on/off all these objects in the map at once, that would be very helpful as well.</p>
  
  <p>Thanks in advance for you help.</p>