首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到角Cli - Dojo模块

找不到角Cli - Dojo模块
EN

Stack Overflow用户
提问于 2018-07-09 11:20:32
回答 1查看 763关注 0票数 2

我正在用Argis4.8JSAPI开发一个角应用程序。我需要Dojo / On函数。我在编译器中也没有错误。但是,当我编译时,我得到了错误“模块未找到:错误:无法解析'dojo / on‘path”。我不能使用Dojo类。我该怎么办?

我的完整代码

代码语言:javascript
复制
import {Component, OnInit, ViewChild, ElementRef, Input, Output, EventEmitter} from '@angular/core';
import {loadModules} from 'esri-loader';
import esri = __esri;
import on = require('dojo/on');


function executeIdentifyTask(event: Event | undefined) {
  console.log(event);
}

@Component({
  selector: 'app-esri-map',
  templateUrl: './esri-map.component.html',
  styleUrls: ['./esri-map.component.css']
})

export class EsriMapComponent implements OnInit {

  @ViewChild('mapViewNode') private mapViewEl: ElementRef;

  constructor() {
  }

  map: esri.Map;
  mapView: esri.MapView;
  layer: esri.MapImageLayer;
  identifyTask: esri.IdentifyTask;

  async initializeMap() {

    try {
      const [EsriMap, EsriMapView, MapImageLayer, IdentifyTask, IdentifyTaskProperties] = await loadModules([
        'esri/Map',
        'esri/views/MapView',
        'esri/layers/MapImageLayer',
        'esri/tasks/IdentifyTask',
        'esri/tasks/support/IdentifyParameters'
      ]);


      this.map = new EsriMap({
        basemap: 'dark-gray'
      });


      this.mapView = new EsriMapView({
        container: this.mapViewEl.nativeElement,
        center: [27.1428, 38.4237],
        zoom: 15,
        map: this.map
      });

      this.layer = new MapImageLayer(
        {url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer'});

      this.map.add(this.layer);
      this.mapView.when(function () {
        on(this.mapView , 'click' , executeIdentifyTask);
      });

    } catch (error) {
      console.log('We have an error: ' + error);
    }

  }

  ngOnInit() {
    this.initializeMap();
  }

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-20 09:25:32

我知道我迟到了一点,但对于其他有类似问题的人,我发现这些错误被描述为可以按下F12键并找到类型,但无法正确编译,通常是由于没有将该类型放在tsconfig.app.json内的types: []数组中造成的。

我在__esri导入中遇到了类似的问题,并一直收到以下错误ERROR in src/app/esri-map/esri-map.component.ts(16,15): error TS2503: Cannot find namespace '__esri'.,并且在将"arcgis-js-api"添加到ERROR in src/app/esri-map/esri-map.component.ts(16,15): error TS2503: Cannot find namespace '__esri'.之后,我的问题就解决了。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51244335

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档