I'm new to OpenLayers 3 and I'm trying to add a property (id, name or label) to a feature to get it back on click later, to identify that particular feature.
Is it possible?
I haven't found any answer doing this yet. Something like:
var point_feature1 = new ol.Feature({ });
point_feature1.setProperties('description', "description 1");
point_feature1.setId(666);
...
And then onclick:
map.on('singleclick', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel,
function(feature, layer) {
console.log("feature",feature.getId());
return [feature, layer];
});
});