From 451172b6113d0f28f2e17c23605c6c3a738e3292 Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Fri, 29 Nov 2019 11:19:04 +0800 Subject: [PATCH] fix(map): temporarily closed amap offset coordinate --- .storybook/webpack.config.js | 8 +-- packages/component/src/control/BaseControl.ts | 2 +- packages/core/src/shaders/projection.glsl | 3 +- packages/maps/src/amap/index.ts | 2 +- stories/Layers/Layers.stories.tsx | 2 + stories/Layers/components/column.tsx | 71 +++++++++++++++++++ 6 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 stories/Layers/components/column.tsx diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 2d3b00e6e0..835dce95cb 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -1,9 +1,9 @@ module.exports = ({ config }) => { - // config.module.rules.push({ - // test: /\.glsl$/, - // loader: 'raw-loader' - // }); + config.module.rules.push({ + test: /\.glsl$/, + loader: 'raw-loader' + }); // config.module.rules.push({ // test: /\.worker\.(js|ts)$/, diff --git a/packages/component/src/control/BaseControl.ts b/packages/component/src/control/BaseControl.ts index 43ff261cc0..8ddfe95acf 100644 --- a/packages/component/src/control/BaseControl.ts +++ b/packages/component/src/control/BaseControl.ts @@ -48,7 +48,7 @@ export default class Control extends EventEmitter { }; } public setPosition(position: PositionName) { - // FIXME: 只是改变位置不需要销毁再重建吧 + // 考虑组件的自动布局,需要销毁重建 // const controlService = this.controlService; // if (controlService) { // controlService.removeControl(this); diff --git a/packages/core/src/shaders/projection.glsl b/packages/core/src/shaders/projection.glsl index 3c977c88a6..f42069a71f 100644 --- a/packages/core/src/shaders/projection.glsl +++ b/packages/core/src/shaders/projection.glsl @@ -105,8 +105,7 @@ vec2 project_pixel_size_to_clipspace(vec2 pixels) { } float project_pixel(float pixel) { - if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 - || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) { + if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // P20 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减1 return pixel * pow(2.0, (19.0 - u_Zoom)); } diff --git a/packages/maps/src/amap/index.ts b/packages/maps/src/amap/index.ts index 3767beccff..869a72022e 100644 --- a/packages/maps/src/amap/index.ts +++ b/packages/maps/src/amap/index.ts @@ -33,7 +33,7 @@ let amapLoaded = false; * 高德地图脚本加载成功等待队列,成功之后依次触发 */ let pendingResolveQueue: Array<() => void> = []; -const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; +const LNGLAT_OFFSET_ZOOM_THRESHOLD = 20; // 暂时关闭 fix 统一不同坐标系,不同底图的高度位置 /** * AMapService diff --git a/stories/Layers/Layers.stories.tsx b/stories/Layers/Layers.stories.tsx index 220f88b076..587c2bf2e0 100644 --- a/stories/Layers/Layers.stories.tsx +++ b/stories/Layers/Layers.stories.tsx @@ -2,6 +2,7 @@ import { storiesOf } from '@storybook/react'; import * as React from 'react'; import Arc2DLineDemo from './components/Arc2DLine'; import ArcLineDemo from './components/Arcline'; +import Column from './components/column'; import HeatMapDemo from './components/HeatMap'; import GridHeatMap from './components/HeatmapGrid'; import LineLayer from './components/Line'; @@ -16,6 +17,7 @@ import RasterLayerDemo from './components/RasterLayer'; storiesOf('图层', module) .add('点图层', () => ) .add('3D点', () => ) + .add('Column', () => ) .add('图片标注', () => ) .add('面3d图层', () => ) .add('线图层', () => ) diff --git a/stories/Layers/components/column.tsx b/stories/Layers/components/column.tsx new file mode 100644 index 0000000000..0e351af6bb --- /dev/null +++ b/stories/Layers/components/column.tsx @@ -0,0 +1,71 @@ +import { PointLayer, Scene } from '@antv/l7'; +import { GaodeMap } from '@antv/l7-maps'; +import * as React from 'react'; +// @ts-ignore +import data from '../data/data.json'; +export default class Column extends React.Component { + // @ts-ignore + private scene: Scene; + + public componentWillUnmount() { + this.scene.destroy(); + } + + public componentDidMount() { + const scene = new Scene({ + id: 'map', + map: new GaodeMap({ + pitch: 66.02383, + style: 'dark', + center: [ 121.400257, 31.25287 ], + zoom: 14.55, + rotation: 134.9507 + }) + }); + + fetch( + 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json' + ) + .then(res => res.json()) + .then(data => { + const pointLayer = new PointLayer({}) + .source(data, { + parser: { + type: 'json', + x: 'longitude', + y: 'latitude' + } + }) + .shape('name', [ + 'cylinder', + 'triangleColumn', + 'hexagonColumn', + 'squareColumn' + ]) + .size('unit_price', h => { + return [ 6, 6, h / 500]; + }) + .color('name', [ '#739DFF', '#61FCBF', '#FFDE74', '#FF896F' ]) + .style({ + opacity: 1.0 + }); + + scene.addLayer(pointLayer); + }) +} + + public render() { + return ( +
+ ); + } +}