Search code examples
google-mapskml

How to link multiple kml in google map


I need to load many more kml files like this. How can i do so?

<script>
  var map;
  var src = 'https://sites.google.com/site/pdbkml/pdbmap/pdb.kmz';

Or is there any way to merge multiple kmls into one?


Solution

  • You can use more kmlLayer

        function initMap() {
          var map = new google.maps.Map(document.getElementById('map'), {
            zoom: 11,
            center: {lat: 45.1, lng: 12.1}
          });
    
          var kmlLayer1 = new google.maps.KmlLayer({
            url: 'http://your_domain/your_path/yourkml1.kml',
            map: map
          });
    
          var kmlLayer2 = new google.maps.KmlLayer({
            url: 'http://your_domain/your_path/yourkml2.kml',
            map: map
          });
          var kmlLayer3 = new google.maps.KmlLayer({
            url: 'http://your_domain/your_path/yourkml3.kml',
            map: map
          });
    
    
        }
      </script>