diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-2b8cd1df4f8a6941bff4108301b5d6a9.json b/.cache/caches/gatsby-transformer-remark/diskstore-2b8cd1df4f8a6941bff4108301b5d6a9.json index 747026c81f..92f7b2e967 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-2b8cd1df4f8a6941bff4108301b5d6a9.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-2b8cd1df4f8a6941bff4108301b5d6a9.json @@ -1 +1 @@ -{"expireTime":9007200828128391000,"key":"transformer-remark-markdown-html-99b5b2f90b0432fb92044e231041ffca-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-99b5b2f90b0432fb92044e231041ffca-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-308215140d91d466921fde8b44e96c70.json b/.cache/caches/gatsby-transformer-remark/diskstore-308215140d91d466921fde8b44e96c70.json index b07a9d57a7..425fdae701 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-308215140d91d466921fde8b44e96c70.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-308215140d91d466921fde8b44e96c70.json @@ -1 +1 @@ -{"expireTime":9007200828128391000,"key":"transformer-remark-markdown-html-b627c832a1f77c6bd67b3f67116e04eb-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-b627c832a1f77c6bd67b3f67116e04eb-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-3cf9cbd2e002119e2f428dfed8eb94da.json b/.cache/caches/gatsby-transformer-remark/diskstore-3cf9cbd2e002119e2f428dfed8eb94da.json index ed3260b29f..7210b21785 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-3cf9cbd2e002119e2f428dfed8eb94da.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-3cf9cbd2e002119e2f428dfed8eb94da.json @@ -1 +1 @@ -{"expireTime":9007200828128391000,"key":"transformer-remark-markdown-html-30a51869612bca077eda87f35f662bad-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-30a51869612bca077eda87f35f662bad-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-57199a69f7efd5decc9f72929e6eaab6.json b/.cache/caches/gatsby-transformer-remark/diskstore-57199a69f7efd5decc9f72929e6eaab6.json index 1d05382ee6..0af459750c 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-57199a69f7efd5decc9f72929e6eaab6.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-57199a69f7efd5decc9f72929e6eaab6.json @@ -1 +1 @@ -{"expireTime":9007200828128384000,"key":"transformer-remark-markdown-html-0b8b19ff19f6a64f7b2cae67200ccd88-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-0b8b19ff19f6a64f7b2cae67200ccd88-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-8a657829abac5ed5e9e205e519d6ded0.json b/.cache/caches/gatsby-transformer-remark/diskstore-8a657829abac5ed5e9e205e519d6ded0.json index 271f4506f0..0e0495ff9c 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-8a657829abac5ed5e9e205e519d6ded0.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-8a657829abac5ed5e9e205e519d6ded0.json @@ -1 +1 @@ -{"expireTime":9007200828128385000,"key":"transformer-remark-markdown-toc-99b5b2f90b0432fb92044e231041ffca-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-{\"heading\":null,\"maxDepth\":6,\"pathToSlugField\":\"fields.slug\"}-","val":""} \ No newline at end of file +{"expireTime":9007200828139761000,"key":"transformer-remark-markdown-toc-99b5b2f90b0432fb92044e231041ffca-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-{\"heading\":null,\"maxDepth\":6,\"pathToSlugField\":\"fields.slug\"}-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-9cf731425f928d78c08a41fa53dbea26.json b/.cache/caches/gatsby-transformer-remark/diskstore-9cf731425f928d78c08a41fa53dbea26.json index a2f0676c66..8448e9c615 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-9cf731425f928d78c08a41fa53dbea26.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-9cf731425f928d78c08a41fa53dbea26.json @@ -1 +1 @@ -{"expireTime":9007200828128384000,"key":"transformer-remark-markdown-html-6e9c5aea4f7ea7c85d806fb35a09a394-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-6e9c5aea4f7ea7c85d806fb35a09a394-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-b196fbb424293a9c110515c8e22586c7.json b/.cache/caches/gatsby-transformer-remark/diskstore-b196fbb424293a9c110515c8e22586c7.json index b2f5f677a9..97fbc8a16e 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-b196fbb424293a9c110515c8e22586c7.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-b196fbb424293a9c110515c8e22586c7.json @@ -1 +1 @@ -{"expireTime":9007200828128384000,"key":"transformer-remark-markdown-html-e0eda26454f7aaeda47989e111060318-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-e0eda26454f7aaeda47989e111060318-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-bed602677090371493b02b2541d3b187.json b/.cache/caches/gatsby-transformer-remark/diskstore-bed602677090371493b02b2541d3b187.json index a151ae916f..9e03c97f0b 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-bed602677090371493b02b2541d3b187.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-bed602677090371493b02b2541d3b187.json @@ -1 +1 @@ -{"expireTime":9007200828128391000,"key":"transformer-remark-markdown-html-51cffb57f20c685f94203902c79f04c6-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-51cffb57f20c685f94203902c79f04c6-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-bfa695e84c9fbd040b43c6cebb35a0a8.json b/.cache/caches/gatsby-transformer-remark/diskstore-bfa695e84c9fbd040b43c6cebb35a0a8.json index 85e22c9c4f..00090fcbce 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-bfa695e84c9fbd040b43c6cebb35a0a8.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-bfa695e84c9fbd040b43c6cebb35a0a8.json @@ -1 +1 @@ -{"expireTime":9007200828128391000,"key":"transformer-remark-markdown-html-94a83b1b7402a40717e5c1b92c85015a-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file +{"expireTime":9007200828184475000,"key":"transformer-remark-markdown-html-94a83b1b7402a40717e5c1b92c85015a-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-dc1901f7f1baf243df1556f52717b2ba.json b/.cache/caches/gatsby-transformer-remark/diskstore-dc1901f7f1baf243df1556f52717b2ba.json index 8d3ddf7016..4c28076b3b 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-dc1901f7f1baf243df1556f52717b2ba.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-dc1901f7f1baf243df1556f52717b2ba.json @@ -1 +1 @@ -{"expireTime":9007200828128384000,"key":"transformer-remark-markdown-toc-57531815410aa78dc10e42270cb201dd-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-{\"heading\":null,\"maxDepth\":6,\"pathToSlugField\":\"fields.slug\"}-","val":""} \ No newline at end of file +{"expireTime":9007200828139769000,"key":"transformer-remark-markdown-toc-57531815410aa78dc10e42270cb201dd-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-{\"heading\":null,\"maxDepth\":6,\"pathToSlugField\":\"fields.slug\"}-","val":""} \ No newline at end of file diff --git a/.cache/caches/gatsby-transformer-remark/diskstore-fbddf0de549e59cfa8bf242898a85984.json b/.cache/caches/gatsby-transformer-remark/diskstore-fbddf0de549e59cfa8bf242898a85984.json index bcf07317d4..0ef099a477 100644 --- a/.cache/caches/gatsby-transformer-remark/diskstore-fbddf0de549e59cfa8bf242898a85984.json +++ b/.cache/caches/gatsby-transformer-remark/diskstore-fbddf0de549e59cfa8bf242898a85984.json @@ -1 +1 @@ -{"expireTime":9007200828128385000,"key":"transformer-remark-markdown-toc-51dbb367647851670b43ae45a9e937df-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-{\"heading\":null,\"maxDepth\":6,\"pathToSlugField\":\"fields.slug\"}-","val":""} \ No newline at end of file +{"expireTime":9007200828139770000,"key":"transformer-remark-markdown-toc-51dbb367647851670b43ae45a9e937df-gatsby-remark-prettiergatsby-remark-prismjsgatsby-remark-external-linksgatsby-remark-autolink-headersgatsby-remark-reading-time-{\"heading\":null,\"maxDepth\":6,\"pathToSlugField\":\"fields.slug\"}-","val":""} \ No newline at end of file diff --git a/.cache/redux.state b/.cache/redux.state index ab421b97e9..d7263dcb6e 100644 Binary files a/.cache/redux.state and b/.cache/redux.state differ diff --git a/examples/heatmap/heatmap/demo/grid.js b/examples/heatmap/heatmap/demo/grid.js deleted file mode 100644 index 8c272874ca..0000000000 --- a/examples/heatmap/heatmap/demo/grid.js +++ /dev/null @@ -1,55 +0,0 @@ -import { Scene } from '@l7/scene'; -import { HeatMapGridLayer } from '@l7/layers'; -const scene = new Scene({ - id: 'map', - style: 'light', - pitch: 0, - center: [116.49434030056, 39.868073421167621], - type: 'amap', - zoom: 16, -}); - -fetch('https://gw.alipayobjects.com/os/basement_prod/c3f8bda2-081b-449d-aa9f-9413b779205b.json') - .then((res) => res.json()) - .then((data) => { - const layer = - new HeatMapGridLayer({ - }) - .source(data, { - parser: { - type: 'json', - x: 'lng', - y: 'lat', - }, - transforms: [ - { - type: 'grid', - size: 50, - field: 'count', - method: 'sum', - }, - ], - }) - .size('sum', (value) => { - return value; - }) - .shape('square') - .style({ - coverage: 0.8, - angle: 0, - opacity: 0.6, - }) - .color('count', [ - '#002466', - '#105CB3', - '#2894E0', - '#CFF6FF', - '#FFF5B8', - '#FFAB5C', - '#F27049', - '#730D1C', - ]); - scene.addLayer(layer); - - - }); diff --git a/examples/heatmap/heatmap/demo/meta.json b/examples/heatmap/heatmap/demo/meta.json index 5c63ae78a9..c36eb6b0b9 100644 --- a/examples/heatmap/heatmap/demo/meta.json +++ b/examples/heatmap/heatmap/demo/meta.json @@ -5,7 +5,7 @@ }, "demos": [ { - "filename": "grid.js", + "filename": "world3d.js", "title": "网格热力图" }, { diff --git a/examples/heatmap/heatmap/demo/world.js b/examples/heatmap/heatmap/demo/world.js index 91a0f2c2f1..ad130f8638 100644 --- a/examples/heatmap/heatmap/demo/world.js +++ b/examples/heatmap/heatmap/demo/world.js @@ -16,7 +16,9 @@ fetch('https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64 new HeatMapLayer({ }) .source(data) - .size('capacity', [0, 1]) // weight映射通道 + .size('capacity', [0, 1]) + .shape('heatmap') + // weight映射通道 .style({ intensity: 10, radius: 5, diff --git a/examples/heatmap/heatmap/demo/world3d.js b/examples/heatmap/heatmap/demo/world3d.js new file mode 100644 index 0000000000..cf4b4abf82 --- /dev/null +++ b/examples/heatmap/heatmap/demo/world3d.js @@ -0,0 +1,41 @@ +import { Scene } from '@l7/scene'; +import { HeatMapLayer } from '@l7/layers'; +const scene = new Scene({ + id: 'map', + style: 'dark', + pitch: 0, + center: [116.49434030056, 39.868073421167621], + type: 'mapbox', + zoom: 3, +}); + +fetch('https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json') + .then((res) => res.json()) + .then((data) => { + const layer = + new HeatMapLayer({ + }) + .source(data) + .size('capacity', [0, 1]) + .shape('heatmap3D') + // weight映射通道 + .style({ + intensity: 10, + radius: 5, + opacity: 1.0, + rampColors: { + colors: [ + '#2E8AE6', + '#69D1AB', + '#DAF291', + '#FFD591', + '#FF7A45', + '#CF1D49', + ], + positions: [0,0.2, 0.4, 0.6, 0.8, 1.0], + }, + }); + scene.addLayer(layer); + + + }); diff --git a/examples/point/basic/demo/meta.json b/examples/point/basic/demo/meta.json index d435544d66..f9c6517f99 100644 --- a/examples/point/basic/demo/meta.json +++ b/examples/point/basic/demo/meta.json @@ -13,6 +13,11 @@ "filename": "world.js", "title": "气泡图 - 电厂装机量" + }, + { + "filename": "text.js", + "title": "文本" + } ] } diff --git a/examples/point/basic/demo/text.js b/examples/point/basic/demo/text.js new file mode 100644 index 0000000000..1d10a9b144 --- /dev/null +++ b/examples/point/basic/demo/text.js @@ -0,0 +1,41 @@ +import { Scene } from '@l7/scene'; +import { PointLayer, PointImageLayer } from '@l7/layers' +const scene = new Scene({ + id: 'map', + pitch: 0, + type: 'amap', + style: 'light', + center: [121.40, 31.258134], + zoom: 15, + minZoom: 10 +}); + +fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json') + .then((res) => res.json()) + .then((data) => { + const pointLayer = + new PointLayer({ + }) + .source(data, { + parser: { + type: 'json', + x: 'longitude', + y: 'latitude' + } + }).shape('circle') + .size('unit_price', [5, 25]) + .color('#5B8FF9') + .label('name') + .style({ + opacity: 0.3, + strokeWidth: 1, + strokeColor: "#5B8FF9", + + }) + + scene.addLayer(pointLayer); + console.log(pointLayer); + + }); + + diff --git a/examples/point/image/demo/size.js b/examples/point/image/demo/size.js index e1932a3a46..44f0d66871 100644 --- a/examples/point/image/demo/size.js +++ b/examples/point/image/demo/size.js @@ -34,7 +34,7 @@ fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9 } }) .shape('name', ['00', '01','02']) - .size('unit_price', [30, 100]) + .size('unit_price', [5, 15]) scene.addLayer(imageLayer); }); diff --git a/packages/core/src/services/layer/ILayerService.ts b/packages/core/src/services/layer/ILayerService.ts index 40da3c56fc..d88002ea0d 100644 --- a/packages/core/src/services/layer/ILayerService.ts +++ b/packages/core/src/services/layer/ILayerService.ts @@ -61,6 +61,7 @@ export interface ILayer { size(field: StyleAttrField, value?: StyleAttributeOption): ILayer; color(field: StyleAttrField, value?: StyleAttributeOption): ILayer; shape(field: StyleAttrField, value?: StyleAttributeOption): ILayer; + label(field: StyleAttrField, value?: StyleAttributeOption): ILayer; // pattern(field: string, value: StyleAttributeOption): ILayer; // filter(field: string, value: StyleAttributeOption): ILayer; // active(option: ActiveOption): ILayer; diff --git a/packages/layers/src/core/BaseLayer.ts b/packages/layers/src/core/BaseLayer.ts index c46e5cbf8e..ab340f8da0 100644 --- a/packages/layers/src/core/BaseLayer.ts +++ b/packages/layers/src/core/BaseLayer.ts @@ -130,6 +130,13 @@ export default class BaseLayer extends EventEmitter @lazyInject(TYPES.ILayerService) protected readonly layerService: ILayerService; + protected enodeOptions: { + [type: string]: { + field: StyleAttributeField; + values?: StyleAttributeOption; + }; + } = {}; + private encodedData: IEncodeFeature[]; private configSchema: object; @@ -142,12 +149,6 @@ export default class BaseLayer extends EventEmitter >; private scaleOptions: IScaleOptions = {}; - private enodeOptions: { - [type: string]: { - field: string; - }; - }; - @lazyInject(TYPES.IInteractionService) private readonly interactionService: IInteractionService; @@ -236,6 +237,10 @@ export default class BaseLayer extends EventEmitter values?: StyleAttributeOption, updateOptions?: Partial, ) { + this.enodeOptions.shape = { + field, + values, + }; this.styleAttributeService.updateStyleAttribute( 'shape', { @@ -254,6 +259,29 @@ export default class BaseLayer extends EventEmitter ); return this; } + public label( + field: StyleAttributeField, + values?: StyleAttributeOption, + updateOptions?: Partial, + ) { + this.styleAttributeService.updateStyleAttribute( + 'label', + { + // @ts-ignore + scale: { + field, + ...this.splitValuesAndCallbackInAttribute( + // @ts-ignore + values, + null, + ), + }, + }, + // @ts-ignore + updateOptions, + ); + return this; + } public source(data: any, options?: ISourceCFG): ILayer { this.sourceOption = { diff --git a/packages/layers/src/heatmap/heatmap.ts b/packages/layers/src/heatmap/heatmap.ts index 747da07589..d03f2dd434 100644 --- a/packages/layers/src/heatmap/heatmap.ts +++ b/packages/layers/src/heatmap/heatmap.ts @@ -56,7 +56,8 @@ export default class HeatMapLayer extends BaseLayer { protected renderModels() { const { clear, useFramebuffer } = this.rendererService; - + const shapeAttr = this.styleAttributeService.getLayerStyleAttribute('shape'); + const shapeType = shapeAttr?.scale?.field || 'heatmap'; useFramebuffer(this.heatmapFramerBuffer, () => { clear({ color: [0, 0, 0, 0], @@ -66,17 +67,19 @@ export default class HeatMapLayer extends BaseLayer { }); this.drawIntensityMode(); }); - this.draw3DHeatMap(); + // this.draw3DHeatMap(); + shapeType === 'heatmap' ? this.drawColorMode(): this.draw3DHeatMap(); // this.drawIntensityMode(); return this; } protected buildModels() { + const shapeAttr = this.styleAttributeService.getLayerStyleAttribute('shape'); + const shapeType = shapeAttr?.scale?.field || 'heatmap'; this.registerBuiltinAttributes(this); this.intensityModel = this.buildHeatMapIntensity(); this.models = [this.intensityModel]; - // this.colorModel = this.buildHeatmapColor(); - this.colorModel = this.build3dHeatMap(); + this.colorModel = shapeType === 'heatmap' ? this.buildHeatmapColor(): this.build3dHeatMap(); this.models.push(this.colorModel); const { rampColors } = this.getStyleOptions(); const imageData = generateColorRamp(rampColors as IColorRamp); @@ -95,8 +98,8 @@ export default class HeatMapLayer extends BaseLayer { height, wrapS: gl.CLAMP_TO_EDGE, wrapT: gl.CLAMP_TO_EDGE, - min: gl.NEAREST, - mag: gl.NEAREST, + min: gl.LINEAR, + mag: gl.LINEAR, }), }); @@ -175,9 +178,9 @@ export default class HeatMapLayer extends BaseLayer { enable: true, func: { srcRGB: gl.ONE, - srcAlpha: 1, + srcAlpha: gl.ONE_MINUS_SRC_ALPHA, dstRGB: gl.ONE, - dstAlpha: 1, + dstAlpha: gl.ONE_MINUS_SRC_ALPHA, }, }, }); @@ -280,7 +283,7 @@ export default class HeatMapLayer extends BaseLayer { private build3dHeatMap() { const { getViewportSize } = this.rendererService; const { width, height } = getViewportSize(); - const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0); + const triangulation = heatMap3DTriangulation(width / 2.0, height / 2.0); this.shaderModuleService.registerModule('heatmap3dColor', { vs: heatmap3DVert, fs: heatmap3DFrag, diff --git a/packages/layers/src/heatmap/shaders/heatmap_3d_frag.glsl b/packages/layers/src/heatmap/shaders/heatmap_3d_frag.glsl index f3b00b62b1..48b48907ea 100644 --- a/packages/layers/src/heatmap/shaders/heatmap_3d_frag.glsl +++ b/packages/layers/src/heatmap/shaders/heatmap_3d_frag.glsl @@ -5,14 +5,13 @@ varying vec2 v_texCoord; varying float v_intensity; void main(){ - float intensity = texture2D(u_texture, v_texCoord).r; + + float intensity = texture2D(u_texture, v_texCoord).r; vec2 ramp_pos = vec2( fract(16.0 * (1.0 - v_intensity)), floor(16.0 * (1.0 - v_intensity)) / 16.0); // vec4 color = texture2D(u_colorTexture,vec2(0.5,1.0-intensity)); vec4 color = texture2D(u_colorTexture,ramp_pos); gl_FragColor = color; - // gl_FragColor.a = color.a * smoothstep(0.0, 0.01, v_intensity) * u_opacity; - // gl_FragColor.a = 0.2; - + gl_FragColor.a = color.a * smoothstep(0.1,0.2,intensity)* u_opacity; } diff --git a/packages/layers/src/heatmap/shaders/heatmap_3d_vert.glsl b/packages/layers/src/heatmap/shaders/heatmap_3d_vert.glsl index e00eec61a5..972323b636 100644 --- a/packages/layers/src/heatmap/shaders/heatmap_3d_vert.glsl +++ b/packages/layers/src/heatmap/shaders/heatmap_3d_vert.glsl @@ -40,6 +40,6 @@ void main() { v_intensity = texture2D(u_texture, v_texCoord).r; fh = toBezier(v_intensity, b).y; - gl_Position = project_common_position_to_clipspace(vec4(position.xy, v_intensity * 50., 1.0)); + gl_Position = project_common_position_to_clipspace(vec4(position.xy, fh * 50., 1.0)); } diff --git a/packages/layers/src/heatmap/shaders/heatmap_frag.glsl b/packages/layers/src/heatmap/shaders/heatmap_frag.glsl index 8e817872e3..a20d904c3b 100644 --- a/packages/layers/src/heatmap/shaders/heatmap_frag.glsl +++ b/packages/layers/src/heatmap/shaders/heatmap_frag.glsl @@ -2,15 +2,16 @@ uniform sampler2D u_texture; uniform sampler2D u_colorTexture; uniform float u_opacity; varying vec2 v_texCoord; +varying float v_intensity; void main(){ - float intensity = texture2D(u_texture, v_texCoord).r; + float intensity = texture2D(u_texture, v_texCoord).r; vec2 ramp_pos = vec2( fract(16.0 * (1.0 - intensity)), floor(16.0 * (1.0 - intensity)) / 16.0); // vec4 color = texture2D(u_colorTexture,vec2(0.5,1.0-intensity)); vec4 color = texture2D(u_colorTexture,ramp_pos); gl_FragColor = color; - gl_FragColor.a = color.a * smoothstep(0.,0.01,intensity) * u_opacity; + gl_FragColor.a = color.a * smoothstep(0.,0.05,intensity) * u_opacity; } diff --git a/packages/layers/src/heatmap/shaders/heatmap_vert.glsl b/packages/layers/src/heatmap/shaders/heatmap_vert.glsl index 177ab3049c..cfa03fe386 100644 --- a/packages/layers/src/heatmap/shaders/heatmap_vert.glsl +++ b/packages/layers/src/heatmap/shaders/heatmap_vert.glsl @@ -3,8 +3,9 @@ attribute vec3 a_Position; attribute vec2 a_Uv; uniform sampler2D u_texture; varying vec2 v_texCoord; +varying float v_intensity; void main() { v_texCoord = a_Uv; - float intensity = texture2D(u_texture, v_texCoord).r; - gl_Position = vec4(a_Position.xy,intensity -0.5, 1.); + v_intensity = texture2D(u_texture, v_texCoord).r; + gl_Position = vec4(a_Position.xy, 0, 1.); } diff --git a/packages/layers/src/plugins/FeatureScalePlugin.ts b/packages/layers/src/plugins/FeatureScalePlugin.ts index 8147ca885b..e1f77ba177 100644 --- a/packages/layers/src/plugins/FeatureScalePlugin.ts +++ b/packages/layers/src/plugins/FeatureScalePlugin.ts @@ -93,14 +93,21 @@ export default class FeatureScalePlugin implements ILayerPlugin { if (scales.some((scale) => scale.type === StyleScaleType.VARIABLE)) { attributeScale.type = StyleScaleType.VARIABLE; scales.forEach((scale) => { - // 如果设置了回调干啥这不需要设置让range - if (!attributeScale.callback && attributeScale.values.length > 0) { - scale.scale.range(attributeScale.values); + // 如果设置了回调, 这不需要设置让range + if (!attributeScale.callback) { + if(attributeScale.values) { + scale.scale.range(attributeScale.values); + } else if(scale.option?.type==='cat') { + + // 如果没有设置初值且 类型为cat,range ==domain; + scale.scale.range(scale.option.domain); + } + } }); } else { // 设置attribute 常量值 常量直接在value取值 - + attributeScale.type = StyleScaleType.CONSTANT; attributeScale.values = scales.map((scale, index) => { return scale.scale(attributeScale.names[index]); }); @@ -166,7 +173,7 @@ export default class FeatureScalePlugin implements ILayerPlugin { type: StyleScaleType.VARIABLE, option: scaleOption, }; - if (!data || !data.length) { + if (!data || !data.length) { if (scaleOption && scaleOption.type) { styleScale.scale = this.createDefaultScale(scaleOption); diff --git a/packages/layers/src/point/text.ts b/packages/layers/src/point/text.ts index d31753e987..9ee0a9c28d 100644 --- a/packages/layers/src/point/text.ts +++ b/packages/layers/src/point/text.ts @@ -164,14 +164,14 @@ export default class TextLayer extends BaseLayer { }); } - private iniTextFont() { + private initTextFont() { const { fontWeight = 'normal', fontFamily } = this.getStyleOptions(); const data = this.getEncodedData(); const characterSet: string[] = []; data.forEach((item: IEncodeFeature) => { - let { text = '' } = item; - text = text.toString(); - for (const char of text) { + let { shape = '' } = item; + shape = shape.toString(); + for (const char of shape) { // 去重 if (characterSet.indexOf(char) === -1) { characterSet.push(char); diff --git a/packages/renderer/src/regl/index.ts b/packages/renderer/src/regl/index.ts index 0683d816e0..d5ab2ec49d 100644 --- a/packages/renderer/src/regl/index.ts +++ b/packages/renderer/src/regl/index.ts @@ -46,7 +46,7 @@ export default class ReglRendererService implements IRendererService { alpha: true, // use TAA instead of MSAA // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1 - antialias: false, + antialias: true, premultipliedAlpha: true, }, // TODO: use extensions