js实例教程-Angular/ionic加载ArcGISAPIforJavaScript报错:TypeError:esri_loader_1.bootstrapisnotafunction

发布时间:2018-11-24 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了js实例教程-Angular/ionic加载ArcGISAPIforJavaScript报错:TypeError:esri_loader_1.bootstrapisnotafunction脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

前言

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

何在Angular项目中使用ArcGIS API for JavaScript。
ArcGIS API for JavaScript加载代码:

 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-loader的说明,导致报错的原因是因为当前项目中的esri-loader的版本过高。
官方给出的说明

解决方法

截止到当前
在执行 npm install --save angular2-esri-loader esri-loader
安装的angular2-esri-loader 和esri-loader版本是

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

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

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

 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 errors   console.error(err); });

前言

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

如何在Angular项目中使用ArcGIS API for JavaScript。
ArcGIS API for JavaScript加载代码:

 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-loader的说明,导致报错的原因是因为当前项目中的esri-loader的版本过高。
官方给出的说明

解决方法

截止到当前
在执行 npm install --save angular2-esri-loader esri-loader
安装的angular2-esri-loader 和esri-loader版本是

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

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

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

 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 errors   console.error(err); });

觉得可用,就经常来吧!Javascript技巧 脚本宝典 欢迎评论哦! js技巧,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的js实例教程-Angular/ionic加载ArcGISAPIforJavaScript报错:TypeError:esri_loader_1.bootstrapisnotafunction全部内容,希望文章能够帮你解决js实例教程-Angular/ionic加载ArcGISAPIforJavaScript报错:TypeError:esri_loader_1.bootstrapisnotafunction所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。