fetch('data/wmsgetfeatureinfo/osm-restaurant-hotel.xml') .then(function (response) { return response.text(); }) .then(function (response) { // this is the standard way to read the features const allFeatures = newWMSGetFeatureInfo().readFeatures(response); document.getElementById('all').innerText = allFeatures.length.toString();
// when specifying the 'layers' options, only the features of those // layers are returned by the format const hotelFeatures = newWMSGetFeatureInfo({ layers: ['hotel'], }).readFeatures(response); document.getElementById('hotel').innerText = hotelFeatures.length.toString();