Leaflet - 如何在弹出窗口中同时显示 PHOTO 和 URL?

Leaflet - how to show both PHOTO and URL in the popup at same time?

我在组合代码以在我的弹出窗口中显示照片和URL时遇到 Leaflet 问题。理想情况下,我希望照片链接到 URL,因此点击它会将访问者带到 URL 的页面。

到目前为止,这是我单独为他们工作的代码:

**URL**:
                if (feature.properties.url) {
                html += '<a href="' + feature.properties.url + '"  target="_blank">Site Internet</a></br>';
            }

 **PHOTO**:
                if (feature.properties.picture) {
                html += '<img src="'+ feature.properties.picture +'" style="width:200px;height:200px;">'+ '</br>';
            } 

有人可以建议如何将二合一命令结合起来吗? 感谢您的帮助!

如果图片存在,这会将图片显示为 link 到 url。您可以添加更多逻辑来满足不存在的 URL。

    if (feature.properties.url) {
        html += '<a href="' + feature.properties.url + '"  target="_blank">';

        if (feature.properties.picture) {
                    html += '<img src="'+ feature.properties.picture +'" style="width:200px;height:200px;">'+ '</a></br>';
        } 
        else {  
             html += 'Site Internet</a></br>';
         }
    }