I must first state that my skills at javascript are about the same as my skills in Spanish. I know barely enough to get myself into trouble and then I go looking for help. anyway I have an application that has a few geoJSON layers in it. I have created a map.forEachFeatureAtPixel function to update a div with some information.
The problem is it looks at all of the layers and I just want it to look at one. this way I can create another function to get some different attributes from another layer. I have looked over the documentation and I see the opt_layerFilter option but I dont know how to apply it (due to my lack of Javascript knowledge). If someone could give me a hint here hopefully I will then be able to read the documentation and stop asking these questions.
function:
var displayFeatureInfo = function(pixel ) {
var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
});
var info = document.getElementById('info');
if (feature) {
info.innerHTML = '<div class="panel panel-info"><div class="panel-heading"><h3 class="panel-title">' + feature.get('Name') +
'</h3></div><div class="panel-body">' + '<dt>API: </dt><dd class="text-info">' + feature.get('API') + '</dd>'
+ '<dt>Status: </dt><dd class="text-info">' + feature.get('Status') + '</dd>' +
'<dt>Legal : </dt><dd class="text-info">' + feature.get('Legal') + '</dd>' +
'<dt>Site Name: </dt><dd class="text-info">' + feature.get('Site_Name') + '</dd>'+'</div>';
} else {
info.innerHTML = ' ';
}
if (feature !== highlight) {
if (highlight) {
featureOverlay.removeFeature(highlight);
}
if (feature) {
featureOverlay.addFeature(feature);
}
highlight = feature;
}
};