2

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

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

该文件在 Chrome 和 Safari 中完美呈现,但在 Firefox 或 IE 中根本不呈现;只有底层的谷歌层。它与 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()
    }   

什么可能导致问题,可以修复吗?

4

1 回答 1

0

当我测试时,看起来你的 poll-by-poll 层在 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 中重新加载。

于 2013-01-07T16:55:14.130 回答