我有一個在其彈出視窗自動填充影像的服務器上運行的傳單地圖。一些彈出視窗包含三個影像。問題是損壞的影像圖示出現在包含較少影像的影像上。我已經嘗試使用 洗掉它們alt="影像圖示損壞的問題",但它不起作用。
附件是應用程式/代碼的鏈接。
function forEachFeatureCC(feature, layer) {
var popUp =
"<h2>" feature.properties.Name "</h2>"
"<img src='" feature.properties.Bildlink "'width='300'</img>"
"<br>" "<br>"
"<h4>" feature.properties.Beschreibung
"<br>" "<br>"
"<img src='" feature.properties.Bildlink_2 "'width='300'</img>"
"<br>" "<br>"
"<img src='" feature.properties.Bildlink_3 "' width='300' alt=''</img>"
"<br>" "<br>";
layer.bindPopup(popUp).update();
}
https://wasserwiki.eu/Wasserwiki_App_Mobile
uj5u.com熱心網友回復:
好的,我明白了,您根本不想顯示缺席的影像。在這種情況下,您可以這樣做:
function getImageHtml(imagelink)
{
return "<img src='" imagelink "' width='300'</img>" "<br>" "<br>";
}
function forEachFeatureCC(feature, layer)
{
var popUp = "<h2>" feature.properties.Name "</h2>";
if (feature.properties.Bildlink) {
popUp = popUp getImageHtml(feature.properties.Bildlink);
}
if (feature.properties.Bildlink_2) {
popUp = popUp getImageHtml(feature.properties.Bildlink_2);
}
if (feature.properties.Bildlink_3) {
popUp = popUp getImageHtml(feature.properties.Bildlink_3);
}
layer.bindPopup(popUp).update();
}
我沒有測驗代碼,所以可能需要一些除錯,但我認為總體思路很清楚?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/514731.html
