cesium billboard跨域问题1
群里小伙伴问道使用billboard加载图片时出现跨域问题,一般认为在服务器端设置
Access-Control-Allow-Origin: *
例如用tomcat发布图片服务,可以这样设置:https://www.cnblogs.com/SmilingEye/p/11158405.html
就可以实现跨域访问,如果服务器不设置,使用<img>标签图片依旧可以跨域访问,但是cesium的billboard就会出现跨域报错问题
Access to image at 'https://xuxinghttps.oss-cn-qingdao.aliyuncs.com/zjl/img/ccb191fb937cd8464435f7da069ff2f3.png' from origin 'http://app.sdzhujialin.com' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
为什么cesium的billboard会出现跨域问题,它的源码里到底是这么加载图片的?
viewer.entities.add({ position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883), billboard :{ image : 'http://localhost:8080/img/ccb191fb937cd8464435f7da069ff2f3.png' } });
查到两篇博客
分析three.js加载图片跨域问题,和cesium的问题类似
https://www.jianshu.com/p/8fa0fb53c183
讲解crossorigin="anonymous"属性,在<img>标签加入crossorigin="anonymous",确实会出现跨域问题
https://www.jianshu.com/p/a45c9d089c93
posted on 2019-08-16 14:46 SmilingEye 阅读(2359) 评论(1) 编辑 收藏 举报