Leaflet: adjust popup to picture size

后端 未结 5 1874
有刺的猬
有刺的猬 2021-02-05 12:54

I\'m trying to include pictures in my leaflet popups, but the popup-size doesn\'t adjust to the picture size. I found a solution to this on github:

https://github.com/Le

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 13:14

    To handle this as someone with limited coding understanding I finally got the following to work for me in the output of the qgis2web plugin when exporting a map forenter code here the web from QGIS 3.10. I first made all my photos the same Width - in my case 400px.

    Then in the index.html file I set a minWidth of 400px as shown below. Everything works fine.

    var popupContent = '\
                    \
                        \
                        \
                    \
                    \
                        \
                
    ' + (feature.properties['Name'] !== null ? autolinker.link(feature.properties['Name'].toLocaleString()) : '') + '
    \
    '; layer.bindPopup(popupContent, {maxHeight: 700, minWidth:400});

提交回复
热议问题