Leaflet JS:IE8中的弹出选项声明失败,但在Firefox和Chrome中没问题

时间:2013-05-08 07:08:27

标签: leaflet

我正在使用最新的LeafletJS库在地图上显示包含某些popop选项的弹出窗口。

它在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);
}

1 个答案:

答案 0 :(得分:2)

在该行上,minWidth和maxWidth选项被输入Math.max。但是你的数字没有数字,因为他们已添加px

所以它应该是

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

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

相关问题