vue leaflet heatmapjs

首先下载包

npm install leaflet
npm install heatmap.js

引入

import * as L from 'leaflet'
import 'leaflet/dist/leaflet.css'
import 'heatmap.js'
import HeatmapOverlay from 'heatmap.js/plugins/leaflet-heatmap'

创建地图

全局变量
window.heatmaplayer = null; //定义全局图层变量
html部分:
<div id="map"></div>
data部分
cfg: {
          // radius should be small ONLY if scaleRadius is true (or small radius is intended)
          // if scaleRadius is false it will be the constant radius used in pixels
          "radius": 0.1,
          "maxOpacity": .8,
          // scales the radius based on map zoom
          "scaleRadius": true,
          // if set to false the heatmap uses the global maximum for colorization
          // if activated: uses the data maximum within the current map boundaries
          //   (there will always be a red spot with useLocalExtremas true)
          "useLocalExtrema": true,
          // which field name in your data represents the latitude - default "lat"
          latField: 'lat',
          // which field name in your data represents the longitude - default "lng"
          lngField: 'lng',
          // which field name in your data represents the data value - default "value"
          valueField: 'count'
        }
模拟数据
data: {
	max: 15,
	data: [
		{
			lat: '',//经纬度
			lng: '',
			count: 0.1 //值
		},
		...
	]
}
js部分
let map = L.map('map', {
    center: [51.505, -0.09],
    zoom: 13
});
window.map = map; //全局
heatmaplayer = new HeatmapOverlay(cfg) //创建heatmap图层
heatmaplayer.addTo(map)//加到地图上
//设置数据
heatmaplayer.setData(this.data)

参考文章链接
https://leafletjs.com/reference-1.6.0.html#map-example
https://www.patrick-wied.at/static/heatmapjs/example-heatmap-leaflet.html
https://www.patrick-wied.at/static/heatmapjs/docs.html
https://www.cnblogs.com/webbest/p/6380751.html
https://blog.csdn.net/seelingzheng/article/details/105963953
https://www.patrick-wied.at/static/heatmapjs/
https://www.jianshu.com/p/1a160f9aefb2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值