Skip to main content

This was solved by using lyr.layer.getLayers() instead of lyr.getLayers(); and then setInfoTemplate to null on each of those layers.

   //On loading the kml file
   kml.on("load", function(lyr){
      //Extract all of the layers from within the KML 
      var layers = lyr.layer.getLayers();
      //For each of those layers, 
      //1. Set click event to re-center the map to original point
      //2. Set the infoTemplate for each layer to null
      // That way whenever the kml layer is clicked there is no infowindow
      // to display to the users.
      array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
      });
    });
   //On loading the kml file
   kml.on("load", function(lyr){
      //Extract all of the layers from within the KML 
      var layers = lyr.layer.getLayers();
      //For each of those layers, 
      //1. Set click event to re-center the map to original point
      //2. Set the infoTemplate for each layer to null
      // That way whenever the kml layer is clicked there is no infowindow
      // to display to the users.
      array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
      });
    });

This was solved by using lyr.layer.getLayers() instead of lyr.getLayers(); and then setInfoTemplate to null on each of those layers.

   //On loading the kml file
   kml.on("load", function(lyr){
      //Extract all of the layers from within the KML 
      var layers = lyr.layer.getLayers();
      //For each of those layers, 
      //1. Set click event to re-center the map to original point
      //2. Set the infoTemplate for each layer to null
      // That way whenever the kml layer is clicked there is no infowindow
      // to display to the users.
      array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
      });
    });
added 373 characters in body
Source Link
EJH
  • 53
  • 5
   //On loading the kml file
   kml.on("load", function(lyr){
      //Extract all of the layers from within the KML 
      var layers = lyr.layer.getLayers();
      //For each of those layers, 
      //1. Set click event to re-center the map to original point
      //2. Set the infoTemplate for each layer to null
      // That way whenever the kml layer is clicked there is no infowindow
      // to display to the users.
      array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
      });
    });
kml.on("load", function(lyr){
    var layers = lyr.layer.getLayers();
    array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
    });
});
   //On loading the kml file
   kml.on("load", function(lyr){
      //Extract all of the layers from within the KML 
      var layers = lyr.layer.getLayers();
      //For each of those layers, 
      //1. Set click event to re-center the map to original point
      //2. Set the infoTemplate for each layer to null
      // That way whenever the kml layer is clicked there is no infowindow
      // to display to the users.
      array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
      });
    });
Source Link
EJH
  • 53
  • 5

kml.on("load", function(lyr){
    var layers = lyr.layer.getLayers();
    array.forEach(layers, function(l) {
        l.on("click", centerMap);
        l.setInfoTemplate(null);
    });
});