@antv/l7-layers 2.8.19 → 2.8.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","LineTriangulation","lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","u_raisingHeight","Number","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","primitive","TRIANGLES","blend","getBlend","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAYA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAA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ToChI,S;;SAAlBK,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
1
+ {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","LineTriangulation","lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","heightfixed","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_heightfixed","Number","u_vertexScale","u_raisingHeight","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","primitive","TRIANGLES","blend","getBlend","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAYA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;;;AAUA,IA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CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EAhUoClI,S;;SAAlBK,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n heightfixed = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
@@ -17,7 +17,7 @@ import { getCullFace, getMask } from '@antv/l7-utils';
17
17
  import BaseModel from '../../core/BaseModel';
18
18
  import { PointFillTriangulation } from '../../core/triangulation';
19
19
  var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying float v_radius;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n float opacity = styleMappingMat[0][0];\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
- var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform float u_isMeter;\n\nvarying float v_radius;\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // radius(16-bit)\n v_radius = a_Size;\n\n // TODO: billboard\n // anti-alias\n \n\n vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec3 aPosition = a_Position;\n if(u_isMeter < 1.0) {\n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n } else {\n // \u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.xy += offset;\n offset.x = 0.0;\n offset.y = 0.0;\n }\n }\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
20
+ var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform float u_isMeter;\n\nvarying float v_radius;\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // radius(16-bit)\n v_radius = a_Size;\n\n // TODO: billboard\n // anti-alias\n \n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec3 aPosition = a_Position;\n if(u_isMeter < 1.0) {\n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n } else {\n // \u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.xy += offset;\n offset.x = 0.0;\n offset.y = 0.0;\n }\n }\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
21
21
  import { Version } from '@antv/l7-maps';
22
22
 
23
23
  var FillImageModel = function (_BaseModel) {
@@ -101,7 +101,7 @@ var FillImageModel = function (_BaseModel) {
101
101
  rotateFlag = -1;
102
102
  }
103
103
 
104
- this.radian = rotation ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
104
+ this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
105
105
 
106
106
  if (this.dataTextureTest && this.dataTextureNeedUpdate({
107
107
  opacity: opacity,
@@ -264,6 +264,24 @@ var FillImageModel = function (_BaseModel) {
264
264
  value: function registerBuiltinAttributes() {
265
265
  var _this2 = this;
266
266
 
267
+ this.styleAttributeService.registerStyleAttribute({
268
+ name: 'rotate',
269
+ type: AttributeType.Attribute,
270
+ descriptor: {
271
+ name: 'a_Rotate',
272
+ buffer: {
273
+ usage: gl.DYNAMIC_DRAW,
274
+ data: [],
275
+ type: gl.FLOAT
276
+ },
277
+ size: 1,
278
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
279
+ var _feature$rotate = feature.rotate,
280
+ rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
281
+ return Array.isArray(rotate) ? [rotate[0]] : [rotate];
282
+ }
283
+ }
284
+ });
267
285
  this.styleAttributeService.registerStyleAttribute({
268
286
  name: 'uv',
269
287
  type: AttributeType.Attribute,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/fillmage.ts"],"names":["AttributeType","gl","getCullFace","getMask","BaseModel","PointFillTriangulation","Version","FillImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","rotation","getDirty","bind","rotateFlag","mapService","version","radian","Math","PI","getRotation","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_RotateMatrix","Float32Array","cos","sin","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","styleAttributeService","createAttributesAndIndices","updateTexture","on","unit","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","enable","getBlend","stencil","cull","face","pointFillFrag","pointFillVert","off","destroy","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","iconMap","getIconMap","shape","extrude","extrudeIndex","Array","isArray"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QASO,eATP;AAUA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,gBAArC;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,sBAAT,QAAuC,0BAAvC;;;AAOA,SAASC,OAAT,QAAwB,eAAxB;;IAEqBC,c;;;;;;;;;;;;;;;;kEACU,C;;;;8DAEF,K;;6DACF,C;;oEA+SD,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADY;AAElBC,UAAAA,GAAG,EAAE,QAFa;AAGlBC,UAAAA,GAAG,EAAE,uBAHa;AAIlBC,UAAAA,MAAM,EAAE;AAJU,SAApB;;AAQA,cAAKC,KAAL,CAAWC,YAAX;;AACA;AACD;;AACD,YAAKT,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BC,QAAAA,GAAG,EAAEd,EAAE,CAACmB,MAFqB;AAI7BJ,QAAAA,GAAG,EAAEf,EAAE,CAACoB,oBAJqB;AAK7BC,QAAAA,gBAAgB,EAAE,KALW;AAM7BC,QAAAA,KAAK,EAAE,IANsB;AAO7BC,QAAA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EVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEzI,EAAE,CAAC0I,YAFJ;AAGN/H,YAAAA,IAAI,EAAE,EAHA;AAIN6C,YAAAA,IAAI,EAAExD,EAAE,CAACyD;AAJH,WAFE;AAQVkF,UAAAA,IAAI,EAAE,CARI;AASVjI,UAAAA,MAAM,EAAE,gBACNkI,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBH,OAArB,CAAQD,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AAEA,mBAAOU,KAAK,CAACC,OAAN,CAAcX,IAAd,IACH,CAACA,IAAI,CAAC,CAAD,CAAJ,GAAU,MAAI,CAAChC,WAAhB,CADG,GAEH,CAAEgC,IAAD,GAAmB,MAAI,CAAChC,WAAzB,CAFJ;AAGD;AApBS;AAHoC,OAAlD;AA0BD;;;;EAjTyCxG,S;;SAAvBG,c","sourcesContent":["import {\n AttributeType,\n gl,\n IAttribute,\n IElements,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getCullFace, getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/image/fillImage_frag.glsl';\nimport pointFillVert from '../shaders/image/fillImage_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class FillImageModel extends BaseModel {\n public meter2coord: number = 1;\n private texture: ITexture2D;\n private isMeter: boolean = false;\n private radian: number = 0; // 旋转的弧度\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n rotation,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n /**\n * rotateFlag\n * L7MAP 1\n * MAPBOX 1\n * GAODE2.x -1\n * GAODE1.x -1\n */\n let rotateFlag = 1;\n if (\n this.mapService.version === 'GAODE2.x' ||\n this.mapService.version === 'GAODE1.x'\n ) {\n rotateFlag = -1;\n }\n // 控制图标的旋转角度(绕 Z 轴旋转)\n this.radian = rotation\n ? (rotateFlag * Math.PI * rotation) / 180\n : (rotateFlag * Math.PI * (this.mapService.getRotation() % 360)) / 180;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n u_RotateMatrix: new Float32Array([\n Math.cos(this.radian),\n Math.sin(this.radian),\n -Math.sin(this.radian),\n Math.cos(this.radian),\n ]),\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_texture: this.texture,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n }),\n ];\n }\n\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n\n public clearModels() {\n this.iconService.off('imageUpdate', this.updateTexture);\n this.texture?.destroy();\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { shape } = feature;\n const { x, y } = iconMap[shape as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n mag: 'linear',\n min: 'linear mipmap nearest',\n mipmap: true,\n });\n // this.layer.render();\n // TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层\n this.layer.renderLayers();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.LINEAR,\n // min: gl.LINEAR,\n min: gl.LINEAR_MIPMAP_LINEAR,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n mipmap: true,\n });\n };\n}\n"],"file":"fillmage.js"}
1
+ {"version":3,"sources":["../../../src/point/models/fillmage.ts"],"names":["AttributeType","gl","getCullFace","getMask","BaseModel","PointFillTriangulation","Version","FillImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","rotation","getDirty","bind","rotateFlag","mapService","version","radian","undefined","Math","PI","getRotation","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_RotateMatrix","Float32Array","cos","sin","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","styleAttributeService","createAttributesAndIndices","updateTexture","on","unit","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","enable","getBlend","stencil","cull","face","pointFillFrag","pointFillVert","off","destroy","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","rotate","Array","isArray","iconMap","getIconMap","shape","extrude","extrudeIndex"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QASO,eATP;AAUA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,gBAArC;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,sBAAT,QAAuC,0BAAvC;;;AAOA,SAASC,OAAT,QAAwB,eAAxB;;IAEqBC,c;;;;;;;;;;;;;;;;kEACU,C;;;;8DAEF,K;;6DACF,C;;oEAsUD,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADY;AAElBC,UAAAA,GAAG,EAAE,QAFa;AAGlBC,UAAAA,GAAG,EAAE,uBAHa;AAIlBC,UAAAA,MAAM,EAAE;AAJU,SAApB;;AAQA,cAAKC,KAAL,CAAWC,YAAX;;AACA;AACD;;AACD,YAAKT,OAAL,GAAeF,eAA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,YAJM,EAKH;AACH,gCAAqBH,OAArB,CAAQD,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AAEA,mBAAOM,KAAK,CAACC,OAAN,CAAcP,IAAd,IACH,CAACA,IAAI,CAAC,CAAD,CAAJ,GAAU,MAAI,CAAChC,WAAhB,CADG,GAEH,CAAEgC,IAAD,GAAmB,MAAI,CAAChC,WAAzB,CAFJ;AAGD;AApBS;AAHoC,OAAlD;AA0BD;;;;EAxUyCzG,S;;SAAvBG,c","sourcesContent":["import {\n AttributeType,\n gl,\n IAttribute,\n IElements,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getCullFace, getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/image/fillImage_frag.glsl';\nimport pointFillVert from '../shaders/image/fillImage_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class FillImageModel extends BaseModel {\n public meter2coord: number = 1;\n private texture: ITexture2D;\n private isMeter: boolean = false;\n private radian: number = 0; // 旋转的弧度\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n rotation,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n /**\n * rotateFlag\n * L7MAP 1\n * MAPBOX 1\n * GAODE2.x -1\n * GAODE1.x -1\n */\n let rotateFlag = 1;\n if (\n this.mapService.version === 'GAODE2.x' ||\n this.mapService.version === 'GAODE1.x'\n ) {\n rotateFlag = -1;\n }\n // 控制图标的旋转角度(绕 Z 轴旋转)\n this.radian =\n rotation !== undefined\n ? (rotateFlag * Math.PI * rotation) / 180\n : (rotateFlag * Math.PI * (this.mapService.getRotation() % 360)) / 180;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n u_RotateMatrix: new Float32Array([\n Math.cos(this.radian),\n Math.sin(this.radian),\n -Math.sin(this.radian),\n Math.cos(this.radian),\n ]),\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_texture: this.texture,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n }),\n ];\n }\n\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n\n public clearModels() {\n this.iconService.off('imageUpdate', this.updateTexture);\n this.texture?.destroy();\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { shape } = feature;\n const { x, y } = iconMap[shape as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n mag: 'linear',\n min: 'linear mipmap nearest',\n mipmap: true,\n });\n // this.layer.render();\n // TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层\n this.layer.renderLayers();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.LINEAR,\n // min: gl.LINEAR,\n min: gl.LINEAR_MIPMAP_LINEAR,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n mipmap: true,\n });\n };\n}\n"],"file":"fillmage.js"}
@@ -1,7 +1,6 @@
1
1
  import _isString from "lodash/isString";
2
2
  import _isNumber from "lodash/isNumber";
3
3
  import _isFunction from "lodash/isFunction";
4
- import _isArray from "lodash/isArray";
5
4
  var WIDTH = 1024;
6
5
 
7
6
  function registerStyleAttribute(fieldName, layer, field, values, updateOptions) {
@@ -45,10 +44,10 @@ function handleStyleFloat(fieldName, layer, styleFloat) {
45
44
  });
46
45
  } else if (_isNumber(styleFloat)) {
47
46
  registerStyleAttribute(fieldName, layer, [styleFloat], undefined);
48
- } else if (_isArray(styleFloat) && styleFloat.length === 2) {
47
+ } else if (Array.isArray(styleFloat) && styleFloat.length === 2) {
49
48
  if (_isString(styleFloat[0]) && _isFunction(styleFloat[1])) {
50
49
  registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);
51
- } else if (_isString(styleFloat[0]) && _isArray(styleFloat[1]) && _isNumber(styleFloat[1][0]) && _isNumber(styleFloat[1][1])) {
50
+ } else if (_isString(styleFloat[0]) && Array.isArray(styleFloat[1]) && _isNumber(styleFloat[1][0]) && _isNumber(styleFloat[1][1])) {
52
51
  registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);
53
52
  } else {
54
53
  registerStyleAttribute(fieldName, layer, [1.0], undefined);
@@ -63,9 +62,9 @@ function handleStyleOffsets(fieldName, layer, styleOffsets) {
63
62
  registerStyleAttribute(fieldName, layer, styleOffsets, function (value) {
64
63
  return value;
65
64
  });
66
- } else if (_isArray(styleOffsets) && styleOffsets.length === 2 && _isString(styleOffsets[0]) && _isFunction(styleOffsets[1])) {
65
+ } else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && _isString(styleOffsets[0]) && _isFunction(styleOffsets[1])) {
67
66
  registerStyleAttribute(fieldName, layer, styleOffsets[0], styleOffsets[1]);
68
- } else if (_isArray(styleOffsets) && styleOffsets.length === 2 && _isNumber(styleOffsets[0]) && _isNumber(styleOffsets[1])) {
67
+ } else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && _isNumber(styleOffsets[0]) && _isNumber(styleOffsets[1])) {
69
68
  registerStyleAttribute(fieldName, layer, styleOffsets, undefined);
70
69
  } else {
71
70
  registerStyleAttribute(fieldName, layer, [0, 0], undefined);
@@ -75,10 +74,10 @@ function handleStyleOffsets(fieldName, layer, styleOffsets) {
75
74
  function handleStyleColor(fieldName, layer, styleColor) {
76
75
  if (_isString(styleColor)) {
77
76
  registerStyleAttribute(fieldName, layer, styleColor, undefined);
78
- } else if (_isArray(styleColor) && styleColor.length === 2) {
77
+ } else if (Array.isArray(styleColor) && styleColor.length === 2) {
79
78
  if (_isString(styleColor[0]) && _isFunction(styleColor[1])) {
80
79
  registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);
81
- } else if (_isString(styleColor[0]) && _isArray(styleColor[1]) && styleColor[1].length > 0) {
80
+ } else if (_isString(styleColor[0]) && Array.isArray(styleColor[1]) && styleColor[1].length > 0) {
82
81
  registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);
83
82
  } else {
84
83
  registerStyleAttribute(fieldName, layer, '#fff', undefined);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/dataMappingStyle.ts"],"names":["WIDTH","registerStyleAttribute","fieldName","layer","field","values","updateOptions","updateStyleAttribute","handleStyleDataMapping","configToUpdate","opacity","handleStyleFloat","strokeWidth","strokeOpacity","stroke","handleStyleColor","offsets","handleStyleOffsets","textOffset","thetaOffset","styleFloat","value","undefined","length","styleOffsets","styleColor"],"mappings":";;;;AAyBA,IAAMA,KAAK,GAAG,IAAd;;AAQA,SAASC,sBAAT,CACEC,SADF,EAEEC,KAFF,EAGEC,KAHF,EAIEC,MAJF,EAKEC,aALF,EAME;AACAH,EAAAA,KAAK,CAACI,oBAAN,CAA2BL,SAA3B,EAAsCE,KAAtC,EAA6CC,MAA7C,EAAqDC,aAArD;AACD;;AAOD,SAASE,sBAAT,CAAgCC,cAAhC,EAAiEN,KAAjE,EAA6E;AAC3E,MAAIM,cAAc,CAACC,OAAnB,EAA4B;AAE1BC,IAAAA,gBAAgB,CAAC,SAAD,EAAYR,KAAZ,EAAmBM,cAAc,CAACC,OAAlC,CAAhB;AACD;;AAED,MAAID,cAAc,CAACG,WAAnB,EAAgC;AAG9BD,IAAAA,gBAAgB,CAAC,aAAD,EAAgBR,KAAhB,EAAuBM,cAAc,CAACG,WAAtC,CAAhB;AACD;;AAED,MAAIH,cAAc,CAACI,aAAnB,EAAkC;AAEhCF,IAAAA,gBAAgB,CAAC,eAAD,EAAkBR,KAAlB,EAAyBM,cAAc,CAACI,aAAxC,CAAhB;AACD;;AAED,MAAIJ,cAAc,CAACK,MAAnB,EAA2B;AAEzBC,IAAAA,gBAAgB,CAAC,QAA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;;AAED,SAASd,sBAAT,EAAiCG,gBAAjC,EAAmDI,gBAAnD","sourcesContent":["import {\n gl,\n ILayer,\n IStyleAttributeUpdateOptions,\n ITexture2D,\n StyleAttributeField,\n StyleAttributeOption,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isArray, isFunction, isNumber, isString } from 'lodash';\n/**\n * 该文件中的工具方法主要用于对 style 中的属性进行 数据映射\n */\n\ninterface IConfigToUpdate {\n thetaOffset?: any;\n opacity?: any;\n strokeOpacity?: any;\n stroke?: any;\n strokeWidth?: any;\n offsets?: any;\n textOffset?: any;\n}\n\n// 画布默认的宽度\nconst WIDTH = 1024;\n\n/**\n * 当 style 中使用的 opacity 不是常数的时候根据数据进行映射\n * @param field\n * @param values\n * @param updateOptions\n */\nfunction registerStyleAttribute(\n fieldName: string,\n layer: ILayer,\n field: StyleAttributeField,\n values?: StyleAttributeOption,\n updateOptions?: Partial<IStyleAttributeUpdateOptions>,\n) {\n layer.updateStyleAttribute(fieldName, field, values, updateOptions);\n}\n\n/**\n * 当样式发生变化时判断是否需要进行数据映射\n * @param configToUpdate\n * @param layer\n */\nfunction handleStyleDataMapping(configToUpdate: IConfigToUpdate, layer: any) {\n if (configToUpdate.opacity) {\n // 处理 style 中 opacity 属性的数据映射\n handleStyleFloat('opacity', layer, configToUpdate.opacity);\n }\n\n if (configToUpdate.strokeWidth) {\n // 处理 style 中 strokeWidth 属性的数据映射\n\n handleStyleFloat('strokeWidth', layer, configToUpdate.strokeWidth);\n }\n\n if (configToUpdate.strokeOpacity) {\n // 处理 style 中 strokeOpacity 属性的数据映射\n handleStyleFloat('strokeOpacity', layer, configToUpdate.strokeOpacity);\n }\n\n if (configToUpdate.stroke) {\n // 处理 style 中 stroke (strokeColor) 属性的数据映射\n handleStyleColor('stroke', layer, configToUpdate.stroke);\n }\n\n if (configToUpdate.offsets) {\n // 处理 style 中 offsets 属性的数据映射\n handleStyleOffsets('offsets', layer, configToUpdate.offsets);\n }\n\n if (configToUpdate.textOffset) {\n // 处理 style 中 textOffset 属性的数据映射\n handleStyleOffsets('textOffset', layer, configToUpdate.textOffset);\n }\n\n if (configToUpdate.thetaOffset) {\n // 处理 style 中 thetaOffset 属性的数据映射\n handleStyleFloat('thetaOffset', layer, configToUpdate.thetaOffset);\n }\n}\n\n/**\n * 根据传入参数 float 的类型和值做相应的操作\n */\nfunction handleStyleFloat(fieldName: string, layer: ILayer, styleFloat: any) {\n if (isString(styleFloat)) {\n // 如果传入的 styleFloat 是 string 类型,那么就认为其对应的是传入数据的字段\n registerStyleAttribute(fieldName, layer, styleFloat, (value: any) => {\n return value;\n });\n } else if (isNumber(styleFloat)) {\n // 传入 number、默认值处理\n registerStyleAttribute(fieldName, layer, [styleFloat], undefined);\n } else if (isArray(styleFloat) && styleFloat.length === 2) {\n // 传入的 styleFloat 是长度为 2 的数组\n if (isString(styleFloat[0]) && isFunction(styleFloat[1])) {\n // 字段回调函数 [string, callback]\n registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);\n } else if (\n isString(styleFloat[0]) &&\n isArray(styleFloat[1]) &&\n isNumber(styleFloat[1][0]) &&\n isNumber(styleFloat[1][1])\n ) {\n // 字段映射 [string, [start: number, end: number]]\n registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, [1.0], undefined);\n }\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, [1.0], undefined);\n }\n}\n/**\n * 根据传入参数 offsets 的类型和值做相应的操作\n * @param fieldName\n * @param layer\n * @param styleOffsets\n */\nfunction handleStyleOffsets(\n fieldName: string,\n layer: ILayer,\n styleOffsets: any,\n) {\n if (isString(styleOffsets)) {\n // 如果传入的 styleOffsets 是 string 类型,那么就认为其对应的是传入数据的字段\n registerStyleAttribute(fieldName, layer, styleOffsets, (value: any) => {\n return value;\n });\n } else if (\n isArray(styleOffsets) &&\n styleOffsets.length === 2 &&\n isString(styleOffsets[0]) &&\n isFunction(styleOffsets[1])\n ) {\n // 字段回调函数 [string, callback]\n registerStyleAttribute(fieldName, layer, styleOffsets[0], styleOffsets[1]);\n } else if (\n isArray(styleOffsets) &&\n styleOffsets.length === 2 &&\n isNumber(styleOffsets[0]) &&\n isNumber(styleOffsets[1])\n ) {\n // 字段映射 [string, [start: number, end: number]]\n registerStyleAttribute(fieldName, layer, styleOffsets, undefined);\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, [0, 0], undefined);\n }\n}\n\n/**\n * 根据传入参数 stroke / color 的类型和值做相应的操作\n * @param fieldName\n * @param layer\n * @param styleColor\n */\nfunction handleStyleColor(fieldName: string, layer: ILayer, styleColor: any) {\n if (isString(styleColor)) {\n // 如果传入的 styleColor 是 string 类型,那么就认为其是颜色值\n registerStyleAttribute(fieldName, layer, styleColor, undefined);\n } else if (isArray(styleColor) && styleColor.length === 2) {\n // 传入的 styleColor 是长度为 2 的数组\n if (isString(styleColor[0]) && isFunction(styleColor[1])) {\n // 字段回调函数 [string, callback]\n registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);\n } else if (\n isString(styleColor[0]) &&\n isArray(styleColor[1]) &&\n styleColor[1].length > 0\n ) {\n // 字段映射 [string, [start: string, end: string]]\n registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, '#fff', undefined);\n }\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, '#fff', undefined);\n }\n}\n\nexport { handleStyleDataMapping, handleStyleFloat, handleStyleColor };\n"],"file":"dataMappingStyle.js"}
1
+ {"version":3,"sources":["../../src/utils/dataMappingStyle.ts"],"names":["WIDTH","registerStyleAttribute","fieldName","layer","field","values","updateOptions","updateStyleAttribute","handleStyleDataMapping","configToUpdate","opacity","handleStyleFloat","strokeWidth","strokeOpacity","stroke","handleStyleColor","offsets","handleStyleOffsets","textOffset","thetaOffset","styleFloat","value","undefined","Array","isArray","length","styleOffsets","styleColor"],"m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AA/B,CAAtB;AACD,GAHD,MAGO,IAAIC,KAAK,CAACC,OAAN,CAAcG,UAAd,KAA6BA,UAAU,CAACF,MAAX,KAAsB,CAAvD,EAA0D;AAE/D,QAAI,UAASE,UAAU,CAAC,CAAD,CAAnB,KAA2B,YAAWA,UAAU,CAAC,CAAD,CAArB,CAA/B,EAA0D;AAExD1B,MAAAA,sBAAsB,CAACC,SAAD,EAAYC,KAAZ,EAAmBwB,UAAU,CAAC,CAAD,CAA7B,EAAkCA,UAAU,CAAC,CAAD,CAA5C,CAAtB;AACD,KAHD,MAGO,IACL,UAASA,UAAU,CAAC,CAAD,CAAnB,KACAJ,KAAK,CAACC,OAAN,CAAcG,UAAU,CAAC,CAAD,CAAxB,CADA,IAEAA,UAAU,CAAC,CAAD,CAAV,CAAcF,MAAd,GAAuB,CAHlB,EAIL;AAEAxB,MAAAA,sBAAsB,CAACC,SAAD,EAAYC,KAAZ,EAAmBwB,UAAU,CAAC,CAAD,CAA7B,EAAkCA,UAAU,CAAC,CAAD,CAA5C,CAAtB;AACD,KAPM,MAOA;AAEL1B,MAAAA,sBAAsB,CAACC,SAAD,EAAYC,KAAZ,EAAmB,MAAnB,EAA2BmB,SAA3B,CAAtB;AACD;AACF,GAhBM,MAgBA;AAELrB,IAAAA,sBAAsB,CAACC,SAAD,EAAYC,KAAZ,EAAmB,MAAnB,EAA2BmB,SAA3B,CAAtB;AACD;AACF;;AAED,SAASd,sBAAT,EAAiCG,gBAAjC,EAAmDI,gBAAnD","sourcesContent":["import {\n gl,\n ILayer,\n IStyleAttributeUpdateOptions,\n ITexture2D,\n StyleAttributeField,\n StyleAttributeOption,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isFunction, isNumber, isString } from 'lodash';\n/**\n * 该文件中的工具方法主要用于对 style 中的属性进行 数据映射\n */\n\ninterface IConfigToUpdate {\n thetaOffset?: any;\n opacity?: any;\n strokeOpacity?: any;\n stroke?: any;\n strokeWidth?: any;\n offsets?: any;\n textOffset?: any;\n}\n\n// 画布默认的宽度\nconst WIDTH = 1024;\n\n/**\n * 当 style 中使用的 opacity 不是常数的时候根据数据进行映射\n * @param field\n * @param values\n * @param updateOptions\n */\nfunction registerStyleAttribute(\n fieldName: string,\n layer: ILayer,\n field: StyleAttributeField,\n values?: StyleAttributeOption,\n updateOptions?: Partial<IStyleAttributeUpdateOptions>,\n) {\n layer.updateStyleAttribute(fieldName, field, values, updateOptions);\n}\n\n/**\n * 当样式发生变化时判断是否需要进行数据映射\n * @param configToUpdate\n * @param layer\n */\nfunction handleStyleDataMapping(configToUpdate: IConfigToUpdate, layer: any) {\n if (configToUpdate.opacity) {\n // 处理 style 中 opacity 属性的数据映射\n handleStyleFloat('opacity', layer, configToUpdate.opacity);\n }\n\n if (configToUpdate.strokeWidth) {\n // 处理 style 中 strokeWidth 属性的数据映射\n\n handleStyleFloat('strokeWidth', layer, configToUpdate.strokeWidth);\n }\n\n if (configToUpdate.strokeOpacity) {\n // 处理 style 中 strokeOpacity 属性的数据映射\n handleStyleFloat('strokeOpacity', layer, configToUpdate.strokeOpacity);\n }\n\n if (configToUpdate.stroke) {\n // 处理 style 中 stroke (strokeColor) 属性的数据映射\n handleStyleColor('stroke', layer, configToUpdate.stroke);\n }\n\n if (configToUpdate.offsets) {\n // 处理 style 中 offsets 属性的数据映射\n handleStyleOffsets('offsets', layer, configToUpdate.offsets);\n }\n\n if (configToUpdate.textOffset) {\n // 处理 style 中 textOffset 属性的数据映射\n handleStyleOffsets('textOffset', layer, configToUpdate.textOffset);\n }\n\n if (configToUpdate.thetaOffset) {\n // 处理 style 中 thetaOffset 属性的数据映射\n handleStyleFloat('thetaOffset', layer, configToUpdate.thetaOffset);\n }\n}\n\n/**\n * 根据传入参数 float 的类型和值做相应的操作\n */\nfunction handleStyleFloat(fieldName: string, layer: ILayer, styleFloat: any) {\n if (isString(styleFloat)) {\n // 如果传入的 styleFloat 是 string 类型,那么就认为其对应的是传入数据的字段\n registerStyleAttribute(fieldName, layer, styleFloat, (value: any) => {\n return value;\n });\n } else if (isNumber(styleFloat)) {\n // 传入 number、默认值处理\n registerStyleAttribute(fieldName, layer, [styleFloat], undefined);\n } else if (Array.isArray(styleFloat) && styleFloat.length === 2) {\n // 传入的 styleFloat 是长度为 2 的数组\n if (isString(styleFloat[0]) && isFunction(styleFloat[1])) {\n // 字段回调函数 [string, callback]\n registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);\n } else if (\n isString(styleFloat[0]) &&\n Array.isArray(styleFloat[1]) &&\n isNumber(styleFloat[1][0]) &&\n isNumber(styleFloat[1][1])\n ) {\n // 字段映射 [string, [start: number, end: number]]\n registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, [1.0], undefined);\n }\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, [1.0], undefined);\n }\n}\n/**\n * 根据传入参数 offsets 的类型和值做相应的操作\n * @param fieldName\n * @param layer\n * @param styleOffsets\n */\nfunction handleStyleOffsets(\n fieldName: string,\n layer: ILayer,\n styleOffsets: any,\n) {\n if (isString(styleOffsets)) {\n // 如果传入的 styleOffsets 是 string 类型,那么就认为其对应的是传入数据的字段\n registerStyleAttribute(fieldName, layer, styleOffsets, (value: any) => {\n return value;\n });\n } else if (\n Array.isArray(styleOffsets) &&\n styleOffsets.length === 2 &&\n isString(styleOffsets[0]) &&\n isFunction(styleOffsets[1])\n ) {\n // 字段回调函数 [string, callback]\n registerStyleAttribute(fieldName, layer, styleOffsets[0], styleOffsets[1]);\n } else if (\n Array.isArray(styleOffsets) &&\n styleOffsets.length === 2 &&\n isNumber(styleOffsets[0]) &&\n isNumber(styleOffsets[1])\n ) {\n // 字段映射 [string, [start: number, end: number]]\n registerStyleAttribute(fieldName, layer, styleOffsets, undefined);\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, [0, 0], undefined);\n }\n}\n\n/**\n * 根据传入参数 stroke / color 的类型和值做相应的操作\n * @param fieldName\n * @param layer\n * @param styleColor\n */\nfunction handleStyleColor(fieldName: string, layer: ILayer, styleColor: any) {\n if (isString(styleColor)) {\n // 如果传入的 styleColor 是 string 类型,那么就认为其是颜色值\n registerStyleAttribute(fieldName, layer, styleColor, undefined);\n } else if (Array.isArray(styleColor) && styleColor.length === 2) {\n // 传入的 styleColor 是长度为 2 的数组\n if (isString(styleColor[0]) && isFunction(styleColor[1])) {\n // 字段回调函数 [string, callback]\n registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);\n } else if (\n isString(styleColor[0]) &&\n Array.isArray(styleColor[1]) &&\n styleColor[1].length > 0\n ) {\n // 字段映射 [string, [start: string, end: string]]\n registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, '#fff', undefined);\n }\n } else {\n // 兼容\n registerStyleAttribute(fieldName, layer, '#fff', undefined);\n }\n}\n\nexport { handleStyleDataMapping, handleStyleFloat, handleStyleColor };\n"],"file":"dataMappingStyle.js"}
@@ -1,9 +1,15 @@
1
1
  var shapeUpdateList = [['circle', 'cylinder'], ['square', 'cylinder'], ['triangle', 'cylinder'], ['pentagon', 'cylinder'], ['hexagon', 'cylinder'], ['octogon', 'cylinder'], ['hexagram', 'cylinder'], ['rhombus', 'cylinder'], ['vesica', 'cylinder']];
2
2
  export function updateShape(layer, lastShape, currentShape) {
3
3
  if (typeof lastShape === 'string' && typeof currentShape === 'string' && lastShape !== currentShape) {
4
+ if (layer.type === 'PointLayer') {
5
+ layer.dataState.dataSourceNeedUpdate = true;
6
+ return;
7
+ }
8
+
4
9
  shapeUpdateList.map(function (shapes) {
5
10
  if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
6
11
  layer.dataState.dataSourceNeedUpdate = true;
12
+ return;
7
13
  }
8
14
  });
9
15
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/updateShape.ts"],"names":["shapeUpdateList","updateShape","layer","lastShape","currentShape","map","shapes","includes","dataState","dataSourceNeedUpdate"],"mappings":"AAGA,IAAMA,eAAe,GAAG,CAEtB,CAAC,QAAD,EAAW,UAAX,CAFsB,EAGtB,CAAC,QAAD,EAAW,UAAX,CAHsB,EAItB,CAAC,UAAD,EAAa,UAAb,CAJsB,EAKtB,CAAC,UAAD,EAAa,UAAb,CALsB,EAMtB,CAAC,SAAD,EAAY,UAAZ,CANsB,EAOtB,CAAC,SAAD,EAAY,UAAZ,CAPsB,EAQtB,CAAC,UAAD,EAAa,UAAb,CARsB,EAStB,CAAC,SAAD,EAAY,UAAZ,CATsB,EAUtB,CAAC,QAAD,EAAW,UAAX,CAVsB,CAAxB;AAYA,OAAO,SAASC,WAAT,CACLC,KADK,EAELC,SAFK,EAGLC,YAHK,EAIC;AACN,MACE,OAAOD,SAAP,KAAqB,QAArB,IACA,OAAOC,YAAP,KAAwB,QADxB,IAEAD,SAAS,KAAKC,YAHhB,EAIE;AACAJ,IAAAA,eAAe,CAACK,GAAhB,CAAoB,UAACC,MAAD,EAAY;AAC9B,UAAIA,MAAM,CAACC,QAAP,CAAgBJ,SAAhB,KAA8BG,MAAM,CAACC,QAAP,CAAgBH,YAAhB,CAAlC,EAAiE;AAE/DF,QAAAA,KAAK,CAACM,SAAN,CAAgBC,oBAAhB,GAAuC,IAAvC;AACD;AACF,KALD;AAMD;AACF","sourcesContent":["import { ILayer, StyleAttributeField } from '@antv/l7-core';\n// TODO: shapeUpdateList 存储一系列的 shape 类型\n// 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)\nconst shapeUpdateList = [\n // PointLayer\n ['circle', 'cylinder'],\n ['square', 'cylinder'],\n ['triangle', 'cylinder'],\n ['pentagon', 'cylinder'],\n ['hexagon', 'cylinder'],\n ['octogon', 'cylinder'],\n ['hexagram', 'cylinder'],\n ['rhombus', 'cylinder'],\n ['vesica', 'cylinder'],\n];\nexport function updateShape(\n layer: ILayer,\n lastShape: StyleAttributeField | undefined,\n currentShape: StyleAttributeField | undefined,\n): void {\n if (\n typeof lastShape === 'string' &&\n typeof currentShape === 'string' &&\n lastShape !== currentShape\n ) {\n shapeUpdateList.map((shapes) => {\n if (shapes.includes(lastShape) && shapes.includes(currentShape)) {\n // TODO: dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流\n layer.dataState.dataSourceNeedUpdate = true;\n }\n });\n }\n}\n"],"file":"updateShape.js"}
1
+ {"version":3,"sources":["../../src/utils/updateShape.ts"],"names":["shapeUpdateList","updateShape","layer","lastShape","currentShape","type","dataState","dataSourceNeedUpdate","map","shapes","includes"],"mappings":"AAGA,IAAMA,eAAe,GAAG,CAEtB,CAAC,QAAD,EAAW,UAAX,CAFsB,EAGtB,CAAC,QAAD,EAAW,UAAX,CAHsB,EAItB,CAAC,UAAD,EAAa,UAAb,CAJsB,EAKtB,CAAC,UAAD,EAAa,UAAb,CALsB,EAMtB,CAAC,SAAD,EAAY,UAAZ,CANsB,EAOtB,CAAC,SAAD,EAAY,UAAZ,CAPsB,EAQtB,CAAC,UAAD,EAAa,UAAb,CARsB,EAStB,CAAC,SAAD,EAAY,UAAZ,CATsB,EAUtB,CAAC,QAAD,EAAW,UAAX,CAVsB,CAAxB;AAYA,OAAO,SAASC,WAAT,CACLC,KADK,EAELC,SAFK,EAGLC,YAHK,EAIC;AACN,MACE,OAAOD,SAAP,KAAqB,QAArB,IACA,OAAOC,YAAP,KAAwB,QADxB,IAEAD,SAAS,KAAKC,YAHhB,EAIE;AACA,QAAIF,KAAK,CAACG,IAAN,KAAe,YAAnB,EAAiC;AAC/BH,MAAAA,KAAK,CAACI,SAAN,CAAgBC,oBAAhB,GAAuC,IAAvC;AACA;AACD;;AAEDP,IAAAA,eAAe,CAACQ,GAAhB,CAAoB,UAACC,MAAD,EAAY;AAC9B,UAAIA,MAAM,CAACC,QAAP,CAAgBP,SAAhB,KAA8BM,MAAM,CAACC,QAAP,CAAgBN,YAAhB,CAAlC,EAAiE;AAE/DF,QAAAA,KAAK,CAACI,SAAN,CAAgBC,oBAAhB,GAAuC,IAAvC;AACA;AACD;AACF,KAND;AAOD;AACF","sourcesContent":["import { ILayer, StyleAttributeField } from '@antv/l7-core';\n// TODO: shapeUpdateList 存储一系列的 shape 类型\n// 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)\nconst shapeUpdateList = [\n // PointLayer\n ['circle', 'cylinder'],\n ['square', 'cylinder'],\n ['triangle', 'cylinder'],\n ['pentagon', 'cylinder'],\n ['hexagon', 'cylinder'],\n ['octogon', 'cylinder'],\n ['hexagram', 'cylinder'],\n ['rhombus', 'cylinder'],\n ['vesica', 'cylinder'],\n];\nexport function updateShape(\n layer: ILayer,\n lastShape: StyleAttributeField | undefined,\n currentShape: StyleAttributeField | undefined,\n): void {\n if (\n typeof lastShape === 'string' &&\n typeof currentShape === 'string' &&\n lastShape !== currentShape\n ) {\n if (layer.type === 'PointLayer') {\n layer.dataState.dataSourceNeedUpdate = true;\n return;\n }\n\n shapeUpdateList.map((shapes) => {\n if (shapes.includes(lastShape) && shapes.includes(currentShape)) {\n // TODO: dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流\n layer.dataState.dataSourceNeedUpdate = true;\n return;\n }\n });\n }\n}\n"],"file":"updateShape.js"}
@@ -43,6 +43,8 @@ var _asyncHook = require("@antv/async-hook");
43
43
 
44
44
  var _l7Core = require("@antv/l7-core");
45
45
 
46
+ var _l7Source = _interopRequireDefault(require("@antv/l7-source"));
47
+
46
48
  var _l7Utils = require("@antv/l7-utils");
47
49
 
48
50
  var _eventemitter = require("eventemitter3");
@@ -416,7 +418,15 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
416
418
  this.layerSource.setData(data, options);
417
419
  } else {
418
420
  this.on('inited', function () {
419
- _this3.layerSource.setData(data, options);
421
+ var currentSource = _this3.getSource();
422
+
423
+ if (!currentSource) {
424
+ _this3.source(new _l7Source.default(data, options));
425
+
426
+ _this3.sourceEvent();
427
+ } else {
428
+ _this3.layerSource.setData(data, options);
429
+ }
420
430
  });
421
431
  }
422
432