Hello all, I have 4 layers in the map and need to determine the layer that I clicked in. I have the following code inside map.on('singleclick', function (evt) , but feature is always undefined.
var displayFeatureInfo = function(pixel ) { var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) { return feature; }); My layers are like this one: var wmsSourceWatermains = new ol.source.TileWMS({ url: 'http://192.168.1.113:8080/geoserver/wms', params: { 'LAYERS': 'watermains' }, serverType: 'geoserver' }); I create the layers with : var layers = [ new ol.layer.Tile({ source: new ol.source.OSM() }), new ol.layer.Tile({ source: wmsSourcePzones }), new ol.layer.Tile({ source: wmsSourcePrv_stns }), new ol.layer.Tile({ source: wmsSourceWatermains }), ]; Any help will be very much appreciated. TIA Jsantos -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Obtaining-Layer-name-when-clicking-on-the-map-tp5221269.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users