This option allows the format to read only features of a given layer. This is useful if you wish to make a single query to a WMS server with multiple layers in it.
25 lines
812 B
JavaScript
25 lines
812 B
JavaScript
goog.require('ol.format.WMSGetFeatureInfo');
|
|
|
|
$.ajax({
|
|
url: './data/wmsgetfeatureinfo/osm-restaurant-hotel.xml',
|
|
success: function(response) {
|
|
|
|
// this is the standard way to read the features
|
|
var allFeatures = new ol.format.WMSGetFeatureInfo().readFeatures(response);
|
|
$('#all').html(allFeatures.length.toString());
|
|
|
|
// when specifying the 'layers' options, only the features of those
|
|
// layers are returned by the format
|
|
var hotelFeatures = new ol.format.WMSGetFeatureInfo({
|
|
layers: ['hotel']
|
|
}).readFeatures(response);
|
|
$('#hotel').html(hotelFeatures.length.toString());
|
|
|
|
var restaurantFeatures = new ol.format.WMSGetFeatureInfo({
|
|
layers: ['restaurant']
|
|
}).readFeatures(response);
|
|
$('#restaurant').html(restaurantFeatures.length.toString());
|
|
|
|
}
|
|
});
|