2013-05-08 55 views
1

我正在使用最新的LeafletJS庫在地圖上顯示某些彈出選項。單張JS:彈出選項聲明在IE8中失敗,但在Firefox和Chrome中可以正常使用

它工作在Firefox和Chrome罰款,但隨着錯誤消息IE8失敗:

參數無效。 leaflet.js,6號線,字符14452

是:

i=Math.min(i,this.options.maxWidth),i=Math.max(i,this.options.minWidth),e.width=i+1+"px",e.whiteSpace="",e.height="" 

這個問題似乎很明顯是與popupOptions聲明 - 在取消的時候他們在IE8中沒有出現的js錯誤,但當然這些選項也不適用。

所以我想知道,語法有什麼問題?

function onEachFeature(feature, layer) { 

    var popupContent = '...'; 

    if (feature.properties && feature.properties.popupContent) { 
     popupContent += feature.properties.popupContent; 
    } 

    var popupOptions = 
    { 
     'minWidth': '491px', 
     'maxWidth': '491px', 
     'closeButton': false 
    } 

    layer.bindPopup(popupContent, popupOptions); 
} 

回答

2

在該行上,minWidth和maxWidth選項被送入Math.max。但你的號碼沒有,因爲他們已經添加了px

所以應該

var popupOptions = 
{ 
    'minWidth': '491', 
    'maxWidth': '491', 
    'closeButton': false 
} 

http://leafletjs.com/reference.html#popup-options

+0

謝謝,僅此而已。曾經習慣於使用css的單位。 – 2013-05-08 08:59:19

相關問題