From 62510767ea15ff2561062707a9d54183aa67152e Mon Sep 17 00:00:00 2001 From: YiQianYao <42212176+2912401452@users.noreply.github.com> Date: Mon, 27 Dec 2021 11:42:45 +0800 Subject: [PATCH] Shihuidev (#900) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 增加着色器的拾取计算控制、完善 arcmini * feat: 完善 enableShaderPick/disableShaderPick 功能 * style: lint style * feat: 补充调用高德地图公交线路查询 demo * style: lint style * feat: 优化弧线的纹理动画 * style: lint style * feat: 去除greatCircle 的纹理动画优化 * feat: 扩展点图层圆柱效果 * feat: 增加几何体的径向渐变配置 * style: lint style * fix: 修复bug 图层触发的事件跟图层设置的zIndex无关,只跟插入图层先后顺序有关 * style: lint style * feat: 补全挤出几何体拾取颜色的光照配置 * style: lint style * fix: 修复圆柱 cull 问题 mapbox amap 不同 * feat: 图层销毁时的内存泄漏 * style: lint style * feat: 平面弧线新增弧线偏移量的数据映射能力 * style: lint style * fix: 修复重复销毁bug * style: lint style * feat: 修复 texture 重复销毁问题 * style: lint style * fix: 修复图层叠加模式下的拾取失效问题 * style: lint style * fix: 修复纹理贴图在 zoom 大于 12 时存在的问题 * fix: 修复水波点颜色偏暗 * feat: 优化点图层的渲染效果,叠加渲染效果 * style: lint style * fix: 修复 layer contextmenu 事件丢失 * fix: 修复 map 类型 resize 失效 * style: lint style * feat: 增加瓦片地图的请求节流 * style: lint style * feat: 优化热力图在 radius 数值比较大时热力点边缘发生裁剪的现象 * style: lint style * fix: 修复resize 后 picking shiqu 拾取失败的问题 * feat: 优化 marker/popup 在容器边缘的表现 * feat: 增加 setEnableRender 方法 * style: lint style * feat: 增加城市图层扫光特效 * style: lint style * feat: 补全拾取色混合配置 * style: lint style * feat: 增加高德地图的面积大小点 * style: lint style * feat: 点优化边缘锯齿 * fix: 修复pointLayer stroke 变暗问题 * fix: 修复混合导致的拾取错误 * feat: add simple point 1.0 * style: lint style * feat: simple point support stroke * style: lint style * feat: 优化 simple point 边缘的锯齿 * style: lint style * feat: add point cylinder raising animate * style: lint style * feat: 优化点图层 icon 在小尺寸下的锯齿问题 * style: lint style * feat: 修复 layer destroy 报错、未清理、未重绘、补充触发 destroy 事件 * fix: 修复 marker 在 cluster getMakers 失效 * style: lint style * feat: 清除 marker layer cluster fix * style: lint style * fix: 修复 markerLayer hide show 方法缺少 cluster 模式下的控制 * style: lint style * feat: 取消在 shape 方法执行后的暴力更新 * style: lint style * feat: 增加图层保底颜色设置 * style: lint style * feat: 将兜底颜色改为 bottomColor * fix: color bottom * style: lint style * feat: 修改颜色兜底判断逻辑 * style: lint style --- packages/layers/src/plugins/DataMappingPlugin.ts | 15 ++++++++------- packages/utils/src/color.ts | 9 +++++++++ stories/Map/components/mapCenter.tsx | 10 +++++----- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/packages/layers/src/plugins/DataMappingPlugin.ts b/packages/layers/src/plugins/DataMappingPlugin.ts index 737c613756..0368197c46 100644 --- a/packages/layers/src/plugins/DataMappingPlugin.ts +++ b/packages/layers/src/plugins/DataMappingPlugin.ts @@ -11,7 +11,7 @@ import { IStyleAttributeService, TYPES, } from '@antv/l7-core'; -import { rgb2arr, unProjectFlat } from '@antv/l7-utils'; +import { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils'; import { inject, injectable } from 'inversify'; import { cloneDeep } from 'lodash'; import 'reflect-metadata'; @@ -214,12 +214,13 @@ export default class DataMappingPlugin implements ILayerPlugin { }); // console.log('params', params) // console.log('attribute', attribute) - // if (attribute.name === 'color') { - // if (params.length === 0 || params[0] === '') { - // return [minimumColor]; - // } - // } - return attribute.mapping ? attribute.mapping(params) : []; + + const mappingResult = attribute.mapping ? attribute.mapping(params) : []; + if (attribute.name === 'color' && !isColor(mappingResult[0])) { + return [minimumColor]; + } + return mappingResult; + // return attribute.mapping ? attribute.mapping(params) : []; } } diff --git a/packages/utils/src/color.ts b/packages/utils/src/color.ts index 08799d8b4a..f817052fe9 100644 --- a/packages/utils/src/color.ts +++ b/packages/utils/src/color.ts @@ -4,6 +4,15 @@ export interface IColorRamp { positions: number[]; colors: string[]; } + +export function isColor(str: any) { + if (typeof str === 'string') { + return !!(d3.color(str) as d3.RGBColor); + } else { + return false; + } +} + export function rgb2arr(str: string) { const color = d3.color(str) as d3.RGBColor; const arr = [0, 0, 0, 0]; diff --git a/stories/Map/components/mapCenter.tsx b/stories/Map/components/mapCenter.tsx index 956d024e64..7a41583b3f 100644 --- a/stories/Map/components/mapCenter.tsx +++ b/stories/Map/components/mapCenter.tsx @@ -49,11 +49,11 @@ export default class GaodeMapComponent extends React.Component { }, ], }; - let trufCircle = new PolygonLayer() - .size('name', [0, 10000, 50000, 30000, 100000]) - .source(data) - .color('#f00') - .shape('fill'); + // let trufCircle = new PolygonLayer() + // .size('name', [0, 10000, 50000, 30000, 100000]) + // .source(data) + // .color('#f00') + // .shape('fill'); let layer = new PointLayer({ zIndex: 2, blend: 'additive' }) .source(