From 2b8ef495d9883f2c42af6bb03457cd47e7cfd1b4 Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Fri, 3 Jul 2020 14:33:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(source):=20=E5=B8=A6=E6=B4=9E=E7=9A=84?= =?UTF-8?q?=E5=A4=9A=E8=BE=B9=E5=BD=A2=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/district/baselayer.zh.md | 6 +++--- docs/api/district/drilldown.en.md | 6 +++--- packages/layers/src/core/triangulation.ts | 1 - packages/source/src/parser/geojson.ts | 2 +- stories/Layers/components/heatmap2.tsx | 15 +++++++++++++-- stories/Layers/components/polygon.tsx | 20 ++++++++++++-------- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/docs/api/district/baselayer.zh.md b/docs/api/district/baselayer.zh.md index e72d58df32..d50f807e4b 100644 --- a/docs/api/district/baselayer.zh.md +++ b/docs/api/district/baselayer.zh.md @@ -34,9 +34,9 @@ order: 2 - strokeWidth 文字描边宽度 - textAllowOverlap 是否允许文字压盖 - opacity 标注透明度 - - spacing: `number` 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近 - - padding: `[number, number]` 文本相对锚点的偏移量 [x, y] - 其他包括 text [style 的配置](../layer/point_layer/text#style) + - spacing: `number` 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近 + - padding: `[number, number]` 文本相对锚点的偏移量 [x, y] + 其他包括 text [style 的配置](../layer/point_layer/text#style) - fill 填充配置项 支持数据映射 - color 图层填充颜色,支持常量和数据映射 diff --git a/docs/api/district/drilldown.en.md b/docs/api/district/drilldown.en.md index 25dd13ed1d..5235db211e 100644 --- a/docs/api/district/drilldown.en.md +++ b/docs/api/district/drilldown.en.md @@ -70,9 +70,9 @@ DrillDownLayer 提供默认提供通过 Layer 的交互事件,实现上钻下 - strokeWidth `number` 描边宽度 `2` - textAllowOverlap: `boolean` 文字是否允许压盖 `true` - opacity `number` 透明度 `1` -- spacing: `number` 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近 -- padding: `[number, number]` 文本相对锚点的偏移量 [x, y] - 其他包括 text [style 的配置](../layer/point_layer/text#style) +- spacing: `number` 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近 +- padding: `[number, number]` 文本相对锚点的偏移量 [x, y] + 其他包括 text [style 的配置](../layer/point_layer/text#style) #### bubbleOption diff --git a/packages/layers/src/core/triangulation.ts b/packages/layers/src/core/triangulation.ts index ac42124cab..608d36635d 100644 --- a/packages/layers/src/core/triangulation.ts +++ b/packages/layers/src/core/triangulation.ts @@ -87,7 +87,6 @@ export function polygonTriangulation(feature: IEncodeFeature) { const { coordinates } = feature; const flattengeo = earcut.flatten(coordinates as number[][][]); const { vertices, dimensions, holes } = flattengeo; - return { indices: earcut(vertices, holes, dimensions), vertices, diff --git a/packages/source/src/parser/geojson.ts b/packages/source/src/parser/geojson.ts index fba2236d81..0a3df86b47 100644 --- a/packages/source/src/parser/geojson.ts +++ b/packages/source/src/parser/geojson.ts @@ -48,7 +48,7 @@ export default function geoJSON( (currentFeature: Feature, featureIndex: number) => { const coord = getCoords(currentFeature); const id = featureIndex; - if (currentFeature.geometry.type === 'Polygon') { + if (currentFeature.geometry.type === 'MultiPolygon') { coord.forEach((coor) => { const dataItem = { ...currentFeature.properties, diff --git a/stories/Layers/components/heatmap2.tsx b/stories/Layers/components/heatmap2.tsx index 03a92b9e45..a7db7d61b0 100644 --- a/stories/Layers/components/heatmap2.tsx +++ b/stories/Layers/components/heatmap2.tsx @@ -27,7 +27,9 @@ export default class HeatMapLayerDemo extends React.Component { ) .then((res) => res.json()) .then((data) => { - const layer = new HeatmapLayer({}) + const layer = new HeatmapLayer({ + autoFit: true, + }) .source(data, { parser: { type: 'json', @@ -36,7 +38,7 @@ export default class HeatMapLayerDemo extends React.Component { }, }) .size('count', [0, 1]) - .shape('heatmap3D') + .shape('heatmap') // weight映射通道 .style({ intensity: 10, @@ -55,6 +57,15 @@ export default class HeatMapLayerDemo extends React.Component { }, }); scene.addLayer(layer); + setTimeout(() => { + layer.style({ + rampColors: { + colors: ['#fee5d9', '#fcbba1', '#fc9272', '#fb6a4a', '#de2d26', '#a50f15'], + positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0], + }, + }); + console.log('更新完成') + }, 2000); }); }); diff --git a/stories/Layers/components/polygon.tsx b/stories/Layers/components/polygon.tsx index 7b45d565b8..7562d48693 100644 --- a/stories/Layers/components/polygon.tsx +++ b/stories/Layers/components/polygon.tsx @@ -133,14 +133,18 @@ export default class TextLayerDemo extends React.Component { }) .size('childrenNum', [10, 100000000]) // .color('red') - .color('childrenNum', [ - '#D92568', - '#E3507E', - '#FC7AAB', - '#F1D3E5', - '#A7B5E3', - '#F2EEFF', - ]) + // .color('childrenNum', [ + // '#D92568', + // '#E3507E', + // '#FC7AAB', + // '#F1D3E5', + // '#A7B5E3', + // '#F2EEFF', + // ]) + .color('childrenNum*name', (childrenNum, name) => { + console.log(childrenNum, name); + return 'red'; + }) .style({ opacity: 1.0, });