首页 >> 大全

Angular/ionic 加载ArcGIS API for JavaScrip

2023-09-02 大全 36 作者:考证青年

前言

在做+/ 加载 API for ,出现以下错误:

这里写图片描述

如何在项目中使用 API for 请参考:

API for 加载代码:

return this.esriLoaderService.load({//ArcGIS API地址url:"http://localhost:8080/arcgis_js_api/library/3.20/3.20/init.js"}).then(()=>{this.esriLoaderService.loadModules(["esri/map","esri/layers/ArcGISTiledMapServiceLayer"]).then(([Map,ArcGISTiledMapServiceLayer])=>{this.map = new Map("mapDiv");let layerUrl = new ArcGISTiledMapServiceLayer("http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer");this.map.addLayer(layerUrl);})
})

错误原因

加载中_加载失败图片_

通过阅读npm上esri-的说明,导致报错的原因是因为当前项目中的esri-的版本过高

官方给出的说明

这里写图片描述

解决方法

截止到当前

在执行 npm --save -esri- esri-

安装的-esri- 和esri-版本是

加载中__加载失败图片

方法一:选择降低esri-的版本,使用当前已有代码

降低esri-版本

npm uninstall --save esri-loader
npm cache clean -f
npm install --save esri-loader@1.0.0

方法二:保留当前esri-load版本,升级现有代码(需要加载 模块)

const options = {url: "http://localhost:8080/arcgis_js_api/library/3.20/3.20/init.js"
};
esriLoader.loadModules(['esri/map'], options)
.then(([Map]) => {// create map with the given options at a DOM node w/ id 'mapNode'let map = new Map('mapNode', {center: [-118, 34.5],zoom: 8,basemap: 'dark-gray'});
})
.catch(err => {// handle any script or module loading errorsconsole.error(err);
});

具体详见npm esri- :

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了