Angular/ionic 加载ArcGIS API for JavaScript报错:TypeError:esri_loader_1.bootstrap is not a function

前言

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

这里写图片描述

    如何在Angular项目中使用ArcGIS API for JavaScript请参考:https://blog.csdn.net/idomyway/article/details/79717710
    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-loaderesri-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);
});

具体详见npm esri-loader :https://www.npmjs.com/package/esri-loader

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值