内网环境的KML文件,无法通过ArcGIS JavaScript API加载KMLayer

用户的 KML文件部署在内网的Web服务器上,设置了正确的MIME type,可以通过URL在浏览器中正确下载到,但是ArcGIS JavaScript API无法通过 KMLayer类进行加载
已邀请:

徐鸿至

赞同来自:

【解决办法】:
kmlayer 默认使用了一个公网的ArcGIS Online kmservice 来处理kml文件,即kml文件需要先上传到公网,如果使用了内网地址,程序是无法正常工作的,参考API文档,如果本机上安装了Portal for ArcGIS的话,可以把kmservice设置为本地portal地址来绕过这个问题:
Note: The KMLLayer uses a utility service from ArcGIS.com, therefore your kml/kmz must be publicly accessible on the internet. If your kml/kmz files are behind the firewall you will need to set the esriConfig.defaults.kmlService to your own utility service. (Requires Portal for ArcGIS).



require([esri/config],function(esriConfig){   esriConfig.defaults.kmlService =http://www.example.com/arcgis/sharing/kml;});

要回复问题请先登录注册