[GIS] Getting Leaflet and image popup from QGIS export working

leafletqgisqgis2leaf

I am a novice in using leaflet, I exported my map layers from QGIS to a working Leaflet map. I am trying to modify the popup to use the attribute so as to get an image popup. i am however stuck as i have read documentation but still unsure. Any leads will help. Currently my popup does a get feature info to show the following.

function pop_dwelling(feature, layer) {
                                        var popupContent = '<table><tr><th  scope="row">house_numb</th><td>' + Autolinker.link(String(feature.properties.house_numb)) + '</td></tr><tr><th  scope="row">photo</th><td>' + Autolinker.link(String(feature.properties.photo)) + '</td></tr><tr><th </td></tr></table>';
                    layer.bindPopup(popupContent);


                }

where the photo is a column in the vector that has the path to the image

Best Answer

Does your column 'photo' contain just a filename? If so, this is what you'd have to do:

  1. Copy all the images to a subfolder in your qgis2leaf output folder (I think there's one there already for images, but can't remember what it's called)
  2. Change the popup code for the photo column from:

    Autolinker.link(String(feature.properties.photo))

to

'<img src="subfoldername/' + feature.properties.photo + '" />'

See if that does the trick.

Related Question