Add layerName option for WMSGetFeatureInfo format
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.
This commit is contained in:
24
examples/getfeatureinfo-layers.js
Normal file
24
examples/getfeatureinfo-layers.js
Normal file
@@ -0,0 +1,24 @@
|
||||
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());
|
||||
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user