错误TS2304:找不到名称“ HeatmapOverlay” +角度10

时间:2020-10-13 11:12:36

标签: javascript angular leaflet

我安装了以下内容:

"@asymmetrik/ngx-leaflet": "^8.1.0",
"leaflet": "^1.7.1",
"leaflet-geosearch": "^3.0.6",
"leaflet-heatmap": "^1.0.0",
"leaflet-timedimension": "^1.1.1",
"leaflet.heat": "https://github.com/Leaflet/Leaflet.heat/tarball/gh-pages",
"@types/leaflet": "^1.5.17",

在index.html中,我添加了以下内容: enter image description here

并添加以下内容:

enter image description here

在map.service.ts中,我编写了以下代码:

import * as L from 'leaflet';
import 'leaflet.heat/dist/leaflet-heat.js';

heatmapLayer = new HeatmapOverlay(this.cfg);

在运行项目时,但在控制台中给我以下错误;在构建项目时,给我构建文件:

src / app / shared / services / map.service.ts中的

ERROR:39:24-TS2304错误: 找不到名称“ HeatmapOverlay”。

1 个答案:

答案 0 :(得分:0)

发生的事情是角度无法识别HeatmapOverlay,您可以执行以下操作之一:

import * as L from 'leaflet';
import 'leaflet.heat/dist/leaflet-heat.js';

heatmapLayer = new (window as any).HeatmapOverlay(this.cfg);

或将其声明为我推荐的类型

declare var HeatmapOverlay:any;