UNPKG

900 BJavaScriptView Raw
1goog.require('ol.format.WMSGetFeatureInfo');
2
3fetch('data/wmsgetfeatureinfo/osm-restaurant-hotel.xml').then(function(response) {
4 return response.text();
5}).then(function(response) {
6
7 // this is the standard way to read the features
8 var allFeatures = new ol.format.WMSGetFeatureInfo().readFeatures(response);
9 document.getElementById('all').innerText = allFeatures.length.toString();
10
11 // when specifying the 'layers' options, only the features of those
12 // layers are returned by the format
13 var hotelFeatures = new ol.format.WMSGetFeatureInfo({
14 layers: ['hotel']
15 }).readFeatures(response);
16 document.getElementById('hotel').innerText = hotelFeatures.length.toString();
17
18 var restaurantFeatures = new ol.format.WMSGetFeatureInfo({
19 layers: ['restaurant']
20 }).readFeatures(response);
21 document.getElementById('restaurant').innerText = restaurantFeatures.length.toString();
22
23});