I want to insert an image in a popup when I click on a layer. I'm successfully using Leaflet-pip but when I want to display an image I've always have undefined
. My url is stored in a postgres
database.
myLayer.on('click', function(a){
var match = leafletPip.pointInLayer(a.latlng, myLayer, false);
if (match.length) {
popUpText = '';
for (var i = 0; i < match.length; i++) {
popUpText += '<div align="center"><b>';
popUpText += match[i].feature.properties.name + '</b></div><br>';
popUpText += '<div align="center">' + match[i].feature.properties.photo + '</div><br>';
popUpText += '';
}
}
var popup = L.popup().setLatLng(a.latlng).setContent(popUpText).openOn(map);
});
My field photo
looks like this
'<img src="https://static.pexels.com/photos/189349/pexels-photo-189349.jpeg" height="150px" width="150px"/>'
How can I solve this ?