diff --git a/packages/source/src/parser/json.ts b/packages/source/src/parser/json.ts index 1fd55994e3..3883d82a3c 100644 --- a/packages/source/src/parser/json.ts +++ b/packages/source/src/parser/json.ts @@ -17,15 +17,9 @@ export default function json(data: IJsonData, cfg: IParserCfg): IParserData { coords = [parseFloat(col[x]), parseFloat(col[y])]; } // 点数据 if (x && y && x1 && y1) { - // 弧线 或者线段 - // const prevLng = col[x]; - // let lng = col[x1]; - // lng += lng - prevLng > 180 ? -360 : - // prevLng - lng > 180 ? 360 : 0; - coords = [ - [parseFloat(col[x]), parseFloat(col[y])], - [parseFloat(col[x1]), parseFloat(col[y1])], - ]; + const from = [parseFloat(col[x]), parseFloat(col[y])]; + const to = [parseFloat(col[x1]), parseFloat(col[y1])]; + coords = [from, to]; } if (coordinates) { let type = 'Polygon'; diff --git a/stories/Layers/components/heatmap3d.tsx b/stories/Layers/components/heatmap3d.tsx new file mode 100644 index 0000000000..fa7699f534 --- /dev/null +++ b/stories/Layers/components/heatmap3d.tsx @@ -0,0 +1,71 @@ +import { HeatmapLayer, Scene } from '@antv/l7'; +import { Mapbox } from '@antv/l7-maps'; +// @ts-ignore +import * as React from 'react'; + +export default class HeatMapLayerDemo extends React.Component { + // @ts-ignore + private scene: Scene; + + public componentWillUnmount() { + this.scene.destroy(); + } + + public async componentDidMount() { + const response = await fetch( + 'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json', + ); + const scene = new Scene({ + id: 'map', + map: new Mapbox({ + center: [121.268, 30.3628], + pitch: 0, + style: 'dark', + zoom: 2, + }), + }); + const data = await response.json(); + + const layer = new HeatmapLayer(); + layer + .source(data) + .shape('heatmap3D') + .size('mag', [0, 1.0]) // weight映射通道 + .style({ + intensity: 2, + radius: 20, + opacity: 1.0, + rampColors: { + colors: [ + '#FF4818', + '#F7B74A', + '#FFF598', + '#91EABC', + '#2EA9A1', + '#206C7C', + ].reverse(), + positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0], + }, + }); + scene.addLayer(layer); + scene.on('loaded', () => { + console.log('scene loaded'); + }); + this.scene = scene; + } + + public render() { + return ( +
+ ); + } +}