title: OpenLayers 3 - Several WMS layers, how to get Feature Info only from visible ones?
body: <p>I have an Openlayers map with several WMS layers from which I want to request feature information through "getGetFeatureInfoUrl". Visibility of layers can be turned on/off in the layer tree. I'd like to, upon clicking somewhere in the map:</p>
  
  <ul>
  <li>Get Feature Info ONLY for layers that are currently visible</li>
  <li>and, if there are more than one layers at the chosen location, get the Feature Info for all of them.</li>
  </ul>
  
  <p>I used the sample code from the <a href="http://openlayers.org/en/v3.9.0/examples/getfeatureinfo-image.html?q=featureinfo" rel="nofollow noreferrer">OpenLayers</a> website. I tried variants of this code bit</p>
  
  <pre><code>var url = layers[2].getSource().getGetFeatureInfoUrl(
      evt1.coordinate, viewResolution, 'EPSG:3857', {
          'INFO_FORMAT': 'text/html',
              'FEATURE_COUNT': '300'
      });
  </code></pre>
  
  <p>like </p>
  
  <p><code>var url = layers[].getSource().getGetFeatureInfoUrl(</code> or 
  <code>var url = layers[1,2].getSource().getGetFeatureInfoUrl(</code>, but either no Feature Info is delivered, or merely for the last layer - regardless of whether it is visible or not.</p>
  
  <p>I created a JSFiddle with two sample layers here: <a href="http://jsfiddle.net/kidalex/j34xzaa3/5/" rel="nofollow noreferrer">http://jsfiddle.net/kidalex/j34xzaa3/5/</a></p>
  
  <p>Similar questions were asked before, like here: <a href="https://gis.stackexchange.com/questions/114297/querying-multiple-wms-layers-in-ol3-and-adding-to-a-single-popup-window">https://gis.stackexchange.com/questions/114297/querying-multiple-wms-layers-in-ol3-and-adding-to-a-single-popup-window</a>; but I cannot fathom how to apply the solutions (JS/OL newbie here).</p>