代码
const map = new BMap.Map('map');
map.centerAndZoom(new BMap.Point(116.404, 39.915), 12);
map.enableScrollWheelZoom(true);
// unit 设置为 'm' 时,size 单位为米,热力半径会固定不变
const heatmap = new BMap.Heatmap({
unit: 'm',
size: 800,
max: 60,
weightField: 'count',
});
map.addLayer(heatmap);
fetch('https://jsapi-demo.bj.bcebos.com/demo_data/beijing_bd09_point.geojson')
.then((res) => res.json())
.then((geojson) => {
heatmap.setData(geojson);
});
通过unit 设置热力图单位,默认 px
预览