答案 0 :(得分:1)
安装传单,ngx-传单,@ types /传单
npm install leaflet
npm install leaflet.heat
npm install @asymmetrik/ngx-leaflet
npm install --save-dev @types/leaflet
在angular.json中导入leaflet.css
"styles": ["../node_modules/leaflet/dist/leaflet.css", "styles.css"]
安装Leaflet.heat并将其导入comp.ts,从资产中导入要使用的地理数据
import 'leaflet.heat/dist/leaflet-heat.js'
import { addressPoints } from '../assets/realworld.10000'
收听onMapReady事件,获取对地图的引用并将热图添加到地图中
onMapReady(map) {
let newAddressPoints = addressPoints.map(function (p) { return [p[0], p[1]]; });
const heat = L.heatLayer(newAddressPoints).addTo(map);
}