title: Google Maps and KML URL
body: <p>I need to build a simple map with checkboxes. Every checkbox must show different KML layer. I don't know how to build this, but in samples on Google Code I found below code.</p>
  
  <p>But when I test all files on localhost (WAMP) KML layer is not showing when I click a checkbox. Other markers in JavaScript are showing normal, only KML is not. </p>
  
  <p>Code to show KML layer is below. Please tell me how I can change code to grab markers.kml from specific URL and not in folder. I need to grab KML from other websites/servers. </p>
  
  <pre><code>/**
   * Toggles KML layer visibility.
   */
  function toggleKmlLayer() {
    if (!kmlLayer) {
      var kmlUrl = window.location.href.substring(
          0, 1 + window.location.href.lastIndexOf('/')) + 'markers.kml';
      kmlLayer = new google.maps.KmlLayer(kmlUrl, {
        preserveViewport: false,
        suppressInfoWindows: false
      });
    }
    showKmlLayer = !showKmlLayer;
    if (showKmlLayer) {
      kmlLayer.setMap(map);
    } else {
      kmlLayer.setMap(null);
    }
  }
  </code></pre>