I am slowly getting to grips with OpenLayers v4.6.5 - I have pop-ups which pop-up - but now I'm attempting to get information into the pop-ups.
Here is the code I am using - I have vector items on my map - a mixture of GeoJSON, from local files, and points from coordinates in the code.
I can open the pop-ups, but all I get is 'undefined.'
//Popup on Pointermove
map.on('pointermove', function (event) {
let layer;
const feature = map.forEachFeatureAtPixel(
event.pixel,
function (feature) {
return feature;
},
{
layerFilter: function (name) {
layer = name;
return true;
}
}
);
if (feature) {
var coordinate = event.coordinate;
var name1 = feature.get('name');
var desk1 = feature.get('description');
// text written inside the popup
content.innerHTML = '<b>'+name1+'<br>'+desk1+'</b>';
overlay.setPosition(coordinate);
}
})
name
anddescription
? And that you have set those properties for your point features you create in your code?