使用产品:SuperMap iClient3D for Cesium 操作系统:win10 x64
文件类型: kml与gltf文件
问题详细描述:参考官网http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iServer/webgl/examples/webgl/editor.html#KML_car小车移动示例,引入kml文件,在kml文件中的模型加载失败,报错 ,前端环境为vue2,资源放在public静态文件夹下,代码如下:
let kmlUrl = "../../../public/static/kml/model.kml";
let kmlDataPromise = Cesium.KmlDataSource.load(kmlUrl, {
camera: window.viewer.scene.camera,
canvas: window.viewer.scene.canvas,
});
kmlDataPromise.then((dataSource)=>{
console.log(dataSource,'dataSource')
console.log(dataSource.entities.values[0],'dataSource.entities.values[0]')
window.viewer.dataSources.add(dataSource);
var entity = dataSource.entities.values[0];
if(entity.path){
entity.path.show = false;
}
})
代码log中dataSource.entities.values[0]没有值
kml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<open>1</open>
<visibility>1</visibility>
<name><![CDATA[test]]></name>
<Placemark>
<name><![CDATA[undefined]]></name>
<description><![CDATA[]]></description>
<Model>
<Location>
<gx:MultiTrack>
<gx:interpolate>1</gx:interpolate>
<gx:Track>
<altitudeMode>absolute</altitudeMode>
<when>2016-05-10T08:55:10.52800000000570435Z</when>
<gx:coord>118.54829881630357 24.802898822941266 59.621359715389794</gx:coord>
<when>2016-05-10T08:55:13.4617916505085304Z</when>
<gx:coord>118.54785398819347 24.803238902245322 60.621821086377864</gx:coord>
<when>2016-05-10T08:55:16.37397817126475275Z</when>
<gx:coord>118.54740781850754 24.803571474903592 60.50922280195892</gx:coord>
</gx:Track>
</gx:MultiTrack>
</Location>
<Orientation>
<heading>270</heading>
<tilt>0</tilt>
<roll>0</roll>
</Orientation>
<Scale>
<x>1</x>
<y>1</y>
<z>1</z>
</Scale>
<Link>
<href>../modelFile/001.gltf</href>
</Link>
</Model>
</Placemark>
</Document>
</kml>
gltf文件路径应该是没有问题的
报错如下
{
"name": "RuntimeError",
"message": "Failed to load model: ../../../public/static/modelFile/001.gltf\nUnexpected token '<', \"<!DOCTYPE \"... is not valid JSON",
"stack": "Error\n at new t$U (http://localhost:81/static/Cesium/Cesium.js:26:468894)\n at http://localhost:81/static/Cesium/Cesium.js:26:2679174\n at _$16.then (http://localhost:81/static/Cesium/Cesium.js:26:509959)\n at http://localhost:81/static/Cesium/Cesium.js:26:510245\n at Q$17 (http://localhost:81/static/Cesium/Cesium.js:26:512591)\n at o (http://localhost:81/static/Cesium/Cesium.js:26:510394)\n at l (http://localhost:81/static/Cesium/Cesium.js:26:510587)\n at _$16.then (http://localhost:81/static/Cesium/Cesium.js:26:509959)\n at http://localhost:81/static/Cesium/Cesium.js:26:510255\n at Q$17 (http://localhost:81/static/Cesium/Cesium.js:26:512591)"
}
请问有没有遇到同样问题的大佬帮我看看,是啥原因导致的?