要渲染的數據:[經度,維度,值]api
例如:函數
var data = [[116.420691626, 39.4574061868, 63],[116.423620497, 39.4574061868, 228],[116.33868323, 39.4596597489, 84]]
在Echarts官方示例的基礎上,修改 renderItem 函數便可spa
function renderItem(params, api) { const [lngIndex, latIndex] = [api.value(0).toFixed(6), api.value(1).toFixed(6)]; const coords = params.context.coords || (params.context.coords = []); const key = lngIndex + '-' + latIndex; const coord = coords[key] || (coords[key] = api.coord([lngIndex, latIndex])); console.log('coord',coord) return { type: 'rect', shape: { x: coord[0], y: coord[1], width: 10, height: 10, }, z: 1000, style: api.style({ stroke: 'rgba(0,0,0,0.1)' }), styleEmphasis: api.styleEmphasis() }; }