Declare an array named kmlArray to store the kml layers. Toggle them using the corresponding marker index.
xxxxxxxxxx
<html>
<head>
<title>KML Toggle</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script src="kmltoggle.js"></script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
https://maps.googleapis.com/maps/api/js?v=3.exp