From 1adc722ebec493c274725e379ed80b86a18869cf Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Wed, 25 Mar 2020 23:56:42 +0800 Subject: [PATCH] =?UTF-8?q?improvement:=20=E8=AE=BE=E7=BD=AEcolor=20size?= =?UTF-8?q?=20=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layers/src/citybuliding/models/build.ts | 2 +- packages/layers/src/line/models/arc.ts | 2 +- packages/layers/src/line/models/arc_3d.ts | 2 +- packages/layers/src/line/models/great_circle.ts | 2 +- .../src/plugins/RegisterStyleAttributePlugin.ts | 2 +- packages/layers/src/point/models/fill.ts | 2 +- packages/layers/src/point/models/image.ts | 2 +- packages/layers/src/point/models/normal.ts | 2 +- packages/layers/src/point/models/text.ts | 2 +- packages/layers/src/polygon/models/extrude.ts | 2 +- packages/source/src/parser/json.ts | 4 ++++ stories/Layers/components/Arcline.tsx | 17 +++++------------ 12 files changed, 19 insertions(+), 22 deletions(-) diff --git a/packages/layers/src/citybuliding/models/build.ts b/packages/layers/src/citybuliding/models/build.ts index 8bf3d709c3..7ac5d6b047 100644 --- a/packages/layers/src/citybuliding/models/build.ts +++ b/packages/layers/src/citybuliding/models/build.ts @@ -85,7 +85,7 @@ export default class CityBuildModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 10 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/line/models/arc.ts b/packages/layers/src/line/models/arc.ts index 0ad24a1936..4ab189b0df 100644 --- a/packages/layers/src/line/models/arc.ts +++ b/packages/layers/src/line/models/arc.ts @@ -73,7 +73,7 @@ export default class ArcModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 1 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/line/models/arc_3d.ts b/packages/layers/src/line/models/arc_3d.ts index a96c6fcade..a168b3c393 100644 --- a/packages/layers/src/line/models/arc_3d.ts +++ b/packages/layers/src/line/models/arc_3d.ts @@ -69,7 +69,7 @@ export default class Arc3DModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 1 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/line/models/great_circle.ts b/packages/layers/src/line/models/great_circle.ts index a7e71e947c..92ac8e0fb1 100644 --- a/packages/layers/src/line/models/great_circle.ts +++ b/packages/layers/src/line/models/great_circle.ts @@ -71,7 +71,7 @@ export default class GreatCircleModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 1 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts b/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts index ebe6b6a275..ececd59929 100644 --- a/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts +++ b/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts @@ -86,7 +86,7 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin { size: 4, update: (feature: IEncodeFeature, featureIdx: number) => { const { color } = feature; - return !color || !color.length ? [0, 0, 0, 0] : color; + return !color || !color.length ? [1, 1, 1, 1] : color; }, }, }); diff --git a/packages/layers/src/point/models/fill.ts b/packages/layers/src/point/models/fill.ts index 3ce962da8b..112fdd0654 100644 --- a/packages/layers/src/point/models/fill.ts +++ b/packages/layers/src/point/models/fill.ts @@ -114,7 +114,7 @@ export default class FillModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 5 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/point/models/image.ts b/packages/layers/src/point/models/image.ts index c0a4948d3a..d8b7c5ff22 100644 --- a/packages/layers/src/point/models/image.ts +++ b/packages/layers/src/point/models/image.ts @@ -67,7 +67,7 @@ export default class ImageModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 5 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/point/models/normal.ts b/packages/layers/src/point/models/normal.ts index c0ef21654e..b7edfbb95e 100644 --- a/packages/layers/src/point/models/normal.ts +++ b/packages/layers/src/point/models/normal.ts @@ -79,7 +79,7 @@ export default class NormalModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 1 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/point/models/text.ts b/packages/layers/src/point/models/text.ts index e828737abe..c8ec36cc3c 100644 --- a/packages/layers/src/point/models/text.ts +++ b/packages/layers/src/point/models/text.ts @@ -231,7 +231,7 @@ export default class TextModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 12 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/layers/src/polygon/models/extrude.ts b/packages/layers/src/polygon/models/extrude.ts index 81edcb5b80..96e93d19f7 100644 --- a/packages/layers/src/polygon/models/extrude.ts +++ b/packages/layers/src/polygon/models/extrude.ts @@ -71,7 +71,7 @@ export default class ExtrudeModel extends BaseModel { vertex: number[], attributeIdx: number, ) => { - const { size } = feature; + const { size = 10 } = feature; return Array.isArray(size) ? [size[0]] : [size as number]; }, }, diff --git a/packages/source/src/parser/json.ts b/packages/source/src/parser/json.ts index cd0a6c6a56..1fd55994e3 100644 --- a/packages/source/src/parser/json.ts +++ b/packages/source/src/parser/json.ts @@ -18,6 +18,10 @@ export default function json(data: IJsonData, cfg: IParserCfg): IParserData { } // 点数据 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])], diff --git a/stories/Layers/components/Arcline.tsx b/stories/Layers/components/Arcline.tsx index 6d0a725e4b..7ab331060f 100644 --- a/stories/Layers/components/Arcline.tsx +++ b/stories/Layers/components/Arcline.tsx @@ -12,7 +12,7 @@ export default class ArcLineDemo extends React.Component { public async componentDidMount() { const response = await fetch( - 'https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt', + 'https://gw.alipayobjects.com/os/bmw-prod/4ededeaa-f290-46b7-a042-08210433e8f9.csv', ); const scene = new Scene({ id: 'map', @@ -36,24 +36,17 @@ export default class ArcLineDemo extends React.Component { y1: 'lat2', }, }) - .size(1) - .shape('arc3d') + // .size(1) + .shape('arc') .select({ color: 'red', }) .active({ color: 'red', }) - .color('rgb(13,64,140)') - .animate({ - enable: true, - interval: 0.1, - duration: 2, - trailLength: 1.0, - }) + // .color('rgb(13,64,140)') .style({ - lineType: 'dash', - opacity: 0.5, + opacity: 1, }); scene.addLayer(lineLayer); scene.render();