function toggleLayer(i) { if(layers[i].getMap() === null) { layers[i].setMap(map); } else { layers[i].setMap(null); } } google.maps.event.addDomListener(window, 'load', initialize); function initialize() { var ctaLayer = []; var mapOptions = { center: new google.maps.LatLng(41.608635, 21.745275), zoom: 9, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); ctaLayer[0] = new google.maps.KmlLayer('http://www.topdizajn.com/google/earth/maps/app/sight.kmz', {preserveViewport: false, suppressInfoWindows: false}); ctaLayer[1] = new google.maps.KmlLayer('http://www.topdizajn.com/google/earth/maps/app/sight.kmz', {preserveViewport: false, suppressInfoWindows: false}); for (var i = 0; i < ctaLayer.length; i++) { ctaLayer[i].setMap(null); } } function myfunction(i) { if (ctaLayer[i].getMap() === null) { ctaLayer[i].setMap(map); } else { ctaLayer[i].setMap(null); alert("Hello!"); } }
Division
Headquarter