OpenLayers2 没有 'Access-Control-Allow-Origin' header 错误

OpenLayers2 No 'Access-Control-Allow-Origin' header error

我正在尝试使用新的 OSM 层更新(已有数年历史的)OL2 JS 应用程序

我的图层代码是:

                        var osm = new OpenLayers.Layer.OSM(
                                "Hydda",
                                ["http://a.tile.openstreetmap.se/hydda/full/${z}/${x}/${y}.png"],
                                {crossOriginKeyword: null}
                        )

如果没有以下错误,我将无法加载磁贴:

Image from origin 'http://a.tile.openstreetmap.se' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mysite' is therefore not allowed access.

有什么想法吗? crossOriginKeyword 声明应该处理这个问题,对吗?

这显然与企业防火墙配置错误有关,而不是 OpenLayers 配置的结果。

您的电话未接tileOptions {}

 var layerOSM2 = new OpenLayers.Layer.OSM(
    "Hydda",
    ["http://a.tile.openstreetmap.se/hydda/full/${z}/${x}/${y}.png"],
    {tileOptions: 
       {crossOriginKeyword: null}
    }
 );