“属性‘heatLayer’在类型 [Leaflet] 上不存在”--prod build

问题描述 投票:0回答:1

我正在尝试使用传单的热图库来构建我的 Angular 9 项目。 编译时效果很好,但是当我尝试 --prod build 时,出现以下错误:

heat-map-map.component.ts 中的错误:112:7 - 错误 TS2339:类型“typeof import("projectPath/ClientApp/node_modules/@types/leaflet/index")”上不存在属性“heatLayer”。

这是我的代码:

var convertedData: [number, number, number][]; convertedData = this.grid.map(g => [g.lat, g.lon, this.data.find(d => d.toID == g.gid)?.time_sec]); // THIS is the important line L.heatLayer(convertedData, { max: max.time_sec }).addTo(this.markersLayer); this.markersLayer.addTo(this.map);
和我的进口:

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

angular leaflet heatmap
1个回答
0
投票
就我而言(Angular 17),导入它是有效的:

import * as L from 'leaflet'; import 'leaflet.heat';
注意:我不需要向 angular.json 脚本数组添加任何内容

© www.soinside.com 2019 - 2024. All rights reserved.