OpenLayers:Vector Layer不在某些浏览器中呈现

时间:2012-12-12 06:41:06

标签: internet-explorer firefox openlayers gml

我是openLayers的新手,并尝试添加GML叠加层:

http://the506.com/elxnmaps/2011/ftontest.html

该文件在Chrome和Safari中呈现完美呈现,但在Firefox或IE中根本不呈现;只有底层的Google图层。它与HTML页面位于同一目录中。我没有尝试似乎工作。这是有问题的代码:

    function init(){
          map = new OpenLayers.Map('map', {
          projection: 'EPSG:3857',
          layers: [(Google layers)],
          center: new OpenLayers.LonLat(-66.6, 46.0).transform('EPSG:4326', 'EPSG:3857'),
          zoom: 10
});
    map.addControl(new OpenLayers.Control.LayerSwitcher());

    (styling rules)

var kmllayer = new OpenLayers.Layer.Vector("Poll-by-Poll Data", {
            protocol: new OpenLayers.Protocol.HTTP({
                url: './13003test.gml',
                format: new OpenLayers.Format.GML({extractAttributes: true})
            }),
            strategies: [new OpenLayers.Strategy.Fixed()],
    visibility: true,
    styleMap: new OpenLayers.StyleMap(style),
    projection: new OpenLayers.Projection('EPSG:4326')
        });

    map.addLayer(kmllayer);

        selectControl = new OpenLayers.Control.SelectFeature(kmllayer,
            {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});

        map.addControl(selectControl);
        selectControl.activate()
    }   

可能导致问题的原因是什么,可以修复吗?

1 个答案:

答案 0 :(得分:0)

当我进行测试时,看起来您的民意调查图层会在Chrome / Firefox中成功加载。但是,stylemap.js的第8行存在语法错误:

var main = new OpenLayers.Style(
{
    fillOpacity: 0.55,
    strokeWidth: 0.4,
    strokeOpacity: 0.9,
    pointRadius: 2,
    strokeColor: "#aaaaaa", // no comma here
}...

删除逗号并尝试在IE中重新加载。

相关问题