I have a question, I need to make more than one GetFeatureInfo (obtaining information under the layer that you click), and for this I need the name of the layer I click on it to get the information.
Anyone know how to get the name of this layer?
This is my getFeatureInfo code:
map.on('click', function(evt) { var pixel = map.getEventPixel(evt.originalEvent); var url = WMS2.getSource().getGetFeatureInfoUrl( evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'application/json', 'propertyName': 'referencia'}); if (url) { var parser = new ol.format.GeoJSON(); $.ajax({url: url, dataType: 'json', success:function(response) { var result = parser.readFeatures(response); if (result.length) { var info2 = []; for (var i = 0, ii = result.length; i < ii; ++i) { info2.push(result.get('referencia')); } document.getElementById("Getfeatureinfo").value = info2; } else { document.getElementById("Getfeatureinfo").value = info2; } }});
أكثر...
Anyone know how to get the name of this layer?
This is my getFeatureInfo code:
map.on('click', function(evt) { var pixel = map.getEventPixel(evt.originalEvent); var url = WMS2.getSource().getGetFeatureInfoUrl( evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'application/json', 'propertyName': 'referencia'}); if (url) { var parser = new ol.format.GeoJSON(); $.ajax({url: url, dataType: 'json', success:function(response) { var result = parser.readFeatures(response); if (result.length) { var info2 = []; for (var i = 0, ii = result.length; i < ii; ++i) { info2.push(result.get('referencia')); } document.getElementById("Getfeatureinfo").value = info2; } else { document.getElementById("Getfeatureinfo").value = info2; } }});
أكثر...