Leaflet: adjust popup to picture size

后端 未结 5 1881
有刺的猬
有刺的猬 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:16

    I had a similar issue with a Leaflet based map in Drupal where I needed to update the popup after loading the images and I managed to solve this based on @frankieandshadow 's answer.

    Here is the code I came up with:

    $(function() {
       var mymap = Drupal.settings.leaflet[0].lMap;
       mymap.on("popupopen", function(e) {
         $(".leaflet-popup-content img:last").one("load", function() {
                e.popup.update();
             });
         });
    });

提交回复
热议问题