Angular Cli-未找到Dojo模块

穆斯塔法·古布兹(Mustafa Gurbuz)

我正在使用Argis 4.8 JS api开发角度应用程序。我需要Dojo / On功能。我在编译器中也没有收到错误。但是,当我编译时,出现错误“找不到模块:错误:无法解析'dojo / on'路径”。我不能使用Dojo类。我该怎么办?

我的完整代码

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();
  }

}
MapLion

我知道我参加聚会有点晚了,但是对于其他有类似问题的人,我发现这些错误通常被描述为可以按F12键并找到类型但无法正确编译的错误。由于未将类型放入types: []数组中的数组而导致tsconfig.app.json

我在__esri导入时遇到了类似的问题,并不断收到以下错误消息ERROR in src/app/esri-map/esri-map.component.ts(16,15): error TS2503: Cannot find namespace '__esri'.,并且添加"arcgis-js-api"到我的文件后tsconfig.app.json,我的问题已解决。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Spring CLI未找到'测试'命令

使用Angular-CLI为特定模块创建组件

使用angular-cli在angular2中获取http:// localhost:4200 / null 404(未找到)

Angular 2-多个模块中的管道重用-未找到错误或重复的定义

Angular CLI安装失败

创建共享模块后,angular-cli测试失败

在Angular2(AngularCLI)中未找到模块elasticsearch

在哪里可以找到Angular 2 CLI TypeScript错误?

Angular:仅当为产品构建时,出现未找到模块错误

Angular 4.4.6的Angular CLI版本

ng serve无法在devDependencies中找到“ @ angular / cli”

将ng-packagr生成的软件包与Angular CLI应用程序集成:未找到模块

Angular 6:找不到模块'@ angular / cli / plugins / webpack'

在Aurelia-CLI中导入Bootstrap 4导致模块未找到

Angular 6无法找到.angular-cli.json并更改outDir

无法安装@ angular / cli

离子服务后未找到模块(webpack)/ hot / emitter @ angular-devkit / build-angular-Ionic 4

错误:找不到模块'@ angular / compiler-cli

angular 8:在Angular cli中生成拦截器时出现“在集合中未找到示意图”拦截器”的错误

angular cli必须使用import来加载ES模块

Jasmine / Karma未找到Angular模块

Angular 2 CLI-西兰花找不到模块

angular-cli更新后找不到模块'@ angular / core'

angular-cli 25.5模块构建失败

错误:找不到模块“@angular-cli/plugins/karma”

未找到 Python cli 模块导入

Angular CLI SCSS 模块在 Windows 上构建失败

Angular 6 使用 2 个路由模块构建“404 页面未找到”

未找到 Angular 模塊