I am using the function to define popup contents in a map, and right now, it createa a popup for every feature I click on the map, no matter what layer it is in. I would like this popup to appear only for features within one layer. I'm sure there is a way I can specify this in the function, but I'm not sure how. I tried using this for line 6 if (feature && layer === layerVector) { but it gave me an error saying that layer is undefined. layerVector is the variable name for the layer I want to use the popup for. Can anyone help? Here is the code:
map.on('click', function(evt) { var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { return feature; }); if (feature) { popup.setPosition(evt.coordinate); content.innerHTML = 'Parcel No: '+ feature.get('parcel')+'
'+ 'Owner: '+ feature.get('primowner') } });
أكثر...
map.on('click', function(evt) { var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { return feature; }); if (feature) { popup.setPosition(evt.coordinate); content.innerHTML = 'Parcel No: '+ feature.get('parcel')+'
'+ 'Owner: '+ feature.get('primowner') } });
أكثر...