Cesium加载倾斜摄影模型,cors跨域的问题No 'Access-Control-Allow-Origin' header is present on the requested resource

    用Cesium加载倾斜摄影模型时,会存在cors跨域的问题,报No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:61203' is therefore not allowed access错误,可通过修改倾斜摄影模型发布的服务器配置解决。

var tileset = new Cesium.Cesium3DTileset({
    url: "http://192.168.7.208:80/Mode/Production.json",
    maximumScreenSpaceError:  1, //根据屏幕调整初始显示精度
    maximumNumberOfLoadedTiles: 1000,
    skipLevelOfDetail: true,
    baseScreenSpaceError: 1024,
    skipScreenSpaceErrorFactor: 16,
    skipLevels: 1,
    immediatelyLoadDesiredLevelOfDetail: false,
    loadSiblings: false,
    cullWithChildrenBounds: true,
    dynamicScreenSpaceError: true,
    dynamicScreenSpaceErrorDensity: 0.00278,
    dynamicScreenSpaceErrorFactor: 4.0,
    dynamicScreenSpaceErrorHeightFalloff: 0.25
});

1.模型通过IIS发布倾斜摄影模型

在网站HTTP响应标头添加如下标头,重启网站,即可解决

名称:Access-Control-Allow-Headers      值:Content-Type,X-Requested-With,token

名称:Access-Control-Allow-Methods      值:GET, POST, PUT, DELETE, OPTIONS

名称:Access-Control-Allow-Origin          值:*

名称:Access-Control-Request-Methods 值:GET, POST, PUT, DELETE, OPTIONS

2.通过Nodejs发布倾斜摄影模型

两种方式解决:https://www.jianshu.com/p/f32211c46325 

 

 

 

 

你可能感兴趣的:(GIS)