diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 469caf67cb..f9b7650183 100755 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -31,7 +31,7 @@ Contributors guide: https://github.com/antvis/L7/blob/master/.github/CONTRIBUTIN ### 💡 需求背景和解决方案 diff --git a/examples/constants.ts b/examples/constants.ts new file mode 100644 index 0000000000..1e39a2f078 --- /dev/null +++ b/examples/constants.ts @@ -0,0 +1,18 @@ +import type { RenderDemoMap, RenderDemoOptions } from './types'; + +export const MAP_TYPES: RenderDemoMap[] = [ + 'Map', + 'GaodeMap', + 'BaiduMap', + 'MapLibre', + 'TencentMap', + 'Mapbox', + 'TMap', + 'GoogleMap', +] as const; + +export const DEFAULT_RENDER_OPTIONS: RenderDemoOptions = { + map: 'Map', + renderer: 'device', + animate: false, +}; diff --git a/examples/demos/bugfix/index.ts b/examples/demos/bugfix/index.ts index 2cc7292673..6d58825610 100644 --- a/examples/demos/bugfix/index.ts +++ b/examples/demos/bugfix/index.ts @@ -1,7 +1,8 @@ export { MapRender as color } from './color'; -export { MapRender as size } from './size'; -export { MapRender as touchend } from './touchend'; +export { MapRender as event_legend } from './event_legend'; export { MapRender as polygon } from './polygon'; -export { MapRender as tile_update } from './tile_update'; +export { MapRender as remove_muti_layer } from './remove-muti-layer'; +export { MapRender as size } from './size'; export { MapRender as text } from './text_offsets'; -export { MapRender as event_legend } from './event_legend'; +export { MapRender as tile_update } from './tile_update'; +export { MapRender as touchend } from './touchend'; diff --git a/examples/demos/bugfix/remove-muti-layer.ts b/examples/demos/bugfix/remove-muti-layer.ts new file mode 100644 index 0000000000..b2950d5e54 --- /dev/null +++ b/examples/demos/bugfix/remove-muti-layer.ts @@ -0,0 +1,319 @@ +import { PolygonLayer, Scene } from '@antv/l7'; +import * as allMap from '@antv/l7-maps'; +import type { RenderDemoOptions } from '../../types'; + +const data1 = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + id: '01', + properties: { + id: 1, + density: 11, + area: 3.141592653589793, + rightPos: { + lng: 120.20854679009427, + lat: 30.289759312473567, + }, + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [120.21773200000003, 30.302992203637245], + [120.21875298581796, 30.302948894941498], + [120.21976413630021, 30.302819386054836], + [120.22075571093397, 30.302604924556675], + [120.22171815793494, 30.302307576377434], + [120.22264220632778, 30.30193020588136], + [120.22351895531074, 30.301476448252767], + [120.22433996004101, 30.30095067445258], + [120.22509731301196, 30.300357949084106], + [120.22578372023696, 30.29970398157531], + [120.22639257150433, 30.298995071149374], + [120.22691800402723, 30.29823804611518], + [120.22735495887522, 30.297440198064148], + [120.2276992296457, 30.296609211608768], + [120.22794750290792, 30.295753090341062], + [120.22809739003313, 30.294880079725182], + [120.22814745010669, 30.293998587668092], + [120.2280972037059, 30.293117103533838], + [120.22794713741399, 30.292244116382022], + [120.22769869903073, 30.291388033217864], + [120.22735428353045, 30.290557098041248], + [120.22691720990578, 30.289759312473567], + [120.22639168912384, 30.289002358726105], + [120.2257827835068, 30.288293525650804], + [120.22509635793018, 30.287639638583972], + [120.22433902331086, 30.28704699365746], + [120.22351807293023, 30.286521297207894], + [120.22264141220631, 30.286067610866056], + [120.22171748259014, 30.285690302853336], + [120.22075518031896, 30.285393005952855], + [120.21976377080624, 30.285178582558256], + [120.21875279949074, 30.28504909713565], + [120.21773200000003, 30.285005796362746], + [120.2167112005093, 30.28504909713565], + [120.21570022919379, 30.285178582558256], + [120.21470881968106, 30.285393005952855], + [120.21374651740989, 30.285690302853336], + [120.21282258779372, 30.286067610866056], + [120.21194592706979, 30.286521297207894], + [120.21112497668918, 30.28704699365746], + [120.21036764206985, 30.287639638583972], + [120.20968121649322, 30.288293525650804], + [120.20907231087618, 30.289002358726105], + [120.20854679009427, 30.289759312473567], + [120.2081097164696, 30.290557098041248], + [120.20776530096931, 30.291388033217864], + [120.20751686258605, 30.292244116382022], + [120.20736679629412, 30.293117103533838], + [120.20731654989335, 30.293998587668092], + [120.2073666099669, 30.294880079725182], + [120.2075164970921, 30.295753090341062], + [120.20776477035433, 30.296609211608768], + [120.20810904112481, 30.297440198064148], + [120.20854599597281, 30.29823804611518], + [120.2090714284957, 30.298995071149374], + [120.20968027976308, 30.29970398157531], + [120.21036668698808, 30.300357949084106], + [120.21112403995903, 30.30095067445258], + [120.21194504468929, 30.301476448252767], + [120.21282179367225, 30.30193020588136], + [120.2137458420651, 30.302307576377434], + [120.21470828906605, 30.302604924556675], + [120.21569986369981, 30.302819386054836], + [120.21671101418207, 30.302948894941498], + [120.21773200000003, 30.302992203637245], + ], + ], + }, + }, + ], +}; +const data2 = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + properties: { + id: 2, + density: 22, + area: 12.566370614359172, + rightPos: { + lng: 120.23505049603307, + lat: 30.284005147499958, + }, + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [120.21773200000003, 30.3119854072745], + [120.21977415806383, 30.311898781955875], + [120.2217966382881, 30.311639740706045], + [120.22377995275484, 30.311210779586737], + [120.22570499154422, 30.31061603192496], + [120.22755320713961, 30.309861228422253], + [120.22930679337095, 30.30895364185113], + [120.23094885716118, 30.30790201687569], + [120.23246358141103, 30.306716485677736], + [120.23383637744625, 30.305408470206746], + [120.23505402555502, 30.303990572002014], + [120.23610480225926, 30.30247645065471], + [120.23697859309758, 30.30088069208723], + [120.23766698983658, 30.299218667924997], + [120.23816337118332, 30.297506387321075], + [120.2384629662307, 30.295760342665886], + [120.23856290003819, 30.293997350672402], + [120.23846222092192, 30.29223439037028], + [120.2381619092075, 30.290488439571295], + [120.23766486737671, 30.28877631138159], + [120.23697589171853, 30.287114492334393], + [120.23610162577349, 30.285518983700303], + [120.23505049603307, 30.284005147499958], + [120.2338326305257, 30.282587558697713], + [120.23245976108386, 30.281279864994566], + [120.2309451102405, 30.28009465556447], + [120.22930326384879, 30.27904333999154], + [120.22755003065353, 30.2781360385674], + [120.22570229016483, 30.277381484998127], + [120.22377783029464, 30.27678694245142], + [120.22179517631207, 30.27635813374636], + [120.21977341275489, 30.276099186352752], + [120.21773200000003, 30.276012592725507], + [120.21569058724513, 30.276099186352752], + [120.21366882368797, 30.27635813374636], + [120.21168616970539, 30.27678694245142], + [120.2097617098352, 30.277381484998127], + [120.20791396934649, 30.2781360385674], + [120.20616073615126, 30.27904333999154], + [120.20451888975954, 30.28009465556447], + [120.20300423891617, 30.281279864994566], + [120.20163136947436, 30.282587558697713], + [120.20041350396696, 30.284005147499958], + [120.19936237422655, 30.285518983700303], + [120.1984881082815, 30.287114492334393], + [120.19779913262333, 30.28877631138159], + [120.19730209079252, 30.290488439571295], + [120.19700177907811, 30.29223439037028], + [120.19690109996185, 30.293997350672402], + [120.19700103376933, 30.295760342665886], + [120.19730062881672, 30.297506387321075], + [120.19779701016346, 30.299218667924997], + [120.19848540690245, 30.30088069208723], + [120.19935919774078, 30.30247645065471], + [120.20040997444504, 30.303990572002014], + [120.20162762255377, 30.305408470206746], + [120.20300041858901, 30.306716485677736], + [120.20451514283886, 30.30790201687569], + [120.20615720662907, 30.30895364185113], + [120.20791079286045, 30.309861228422253], + [120.2097590084558, 30.31061603192496], + [120.21168404724521, 30.311210779586737], + [120.21366736171194, 30.311639740706045], + [120.21568984193621, 30.311898781955875], + [120.21773200000003, 30.3119854072745], + ], + ], + }, + }, + ], +}; +const data3 = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + properties: { + id: 3, + area: 28.274333882308138, + density: 1, + rightPos: { + lng: 120.21773200000003, + lat: 30.320978610911727, + }, + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [120.21773200000003, 30.320978610911727], + [120.22079551683832, 30.320848661038823], + [120.22382950615737, 30.320460063936846], + [120.22680472573462, 30.31981656505397], + [120.22969250115753, 30.318924366581857], + [120.23246500279812, 30.31779206753472], + [120.23509551454973, 30.31643058067988], + [120.23755869170974, 30.314853027129736], + [120.2398308055025, 30.313074609622266], + [120.24188997187018, 30.311112465724232], + [120.24371636231784, 30.308985502385614], + [120.24529239477944, 30.306714213454125], + [120.24660290266935, 30.304320481922765], + [120.24763528050285, 30.301827368829496], + [120.24837960469955, 30.29925889085592], + [120.24882872843001, 30.29663978877863], + [120.24897834961936, 30.29399528901298], + [120.24882705148536, 30.29135086055287], + [120.24837631525429, 30.288731969652023], + [120.24763050496843, 30.286163834610385], + [120.2465968245668, 30.28367118302587], + [120.2452852476867, 30.281278013844588], + [120.24370842089364, 30.27900736649369], + [120.24188154129892, 30.276881099310618], + [120.2398222097663, 30.27491967939022], + [120.23755026113787, 30.273141985860427], + [120.2350875731244, 30.27156512846593], + [120.23245785570393, 30.270204283191838], + [120.22968642305335, 30.26907254649496], + [120.2267999501987, 30.2681808095318], + [120.22382621671096, 30.26753765358102], + [120.22079383989308, 30.267149267655576], + [120.21773200000003, 30.267019389088258], + [120.21467016010696, 30.267149267655576], + [120.21163778328908, 30.26753765358102], + [120.20866404980134, 30.2681808095318], + [120.2057775769467, 30.26907254649496], + [120.2030061442961, 30.270204283191838], + [120.20037642687565, 30.27156512846593], + [120.19791373886217, 30.273141985860427], + [120.19564179023374, 30.27491967939022], + [120.19358245870113, 30.276881099310618], + [120.19175557910638, 30.27900736649369], + [120.19017875231334, 30.281278013844588], + [120.18886717543323, 30.28367118302587], + [120.18783349503161, 30.286163834610385], + [120.18708768474575, 30.288731969652023], + [120.18663694851467, 30.29135086055287], + [120.18648565038066, 30.29399528901298], + [120.18663527157001, 30.29663978877863], + [120.18708439530049, 30.29925889085592], + [120.18782871949719, 30.301827368829496], + [120.18886109733069, 30.304320481922765], + [120.1901716052206, 30.306714213454125], + [120.1917476376822, 30.308985502385614], + [120.19357402812986, 30.311112465724232], + [120.19563319449753, 30.313074609622266], + [120.19790530829029, 30.314853027129736], + [120.2003684854503, 30.31643058067988], + [120.2029989972019, 30.31779206753472], + [120.2057714988425, 30.318924366581857], + [120.20865927426541, 30.31981656505397], + [120.21163449384267, 30.320460063936846], + [120.21466848316172, 30.320848661038823], + [120.21773200000003, 30.320978610911727], + ], + ], + }, + }, + ], +}; + +export function MapRender(options: RenderDemoOptions) { + const scene = new Scene({ + id: 'map', + renderer: options.renderer, + map: new allMap[options.map]({ + style: 'light', + center: [120.11155128479004, 30.24868703665976], + zoom: 11, + }), + }); + scene.on('loaded', () => { + const layer = new PolygonLayer({}) + .source(data1) + .scale('density', { + type: 'quantile', + }) + .color('#1990ff1a') + .shape('fill'); + scene.addLayer(layer); + + const layer2 = new PolygonLayer({}) + .source(data2) + .scale('density', { + type: 'quantile', + }) + .color('#1990ff1a') + .shape('fill'); + scene.addLayer(layer2); + + const layer3 = new PolygonLayer({}) + .source(data3) + .scale('density', { + type: 'quantile', + }) + .color('#1990ff1a') + .shape('fill'); + scene.addLayer(layer3); + + setTimeout(() => { + const layers = scene.getLayers(); + for (const layer of layers) { + scene.removeLayer(layer); + } + }, 2000); + }); +} diff --git a/examples/demos/index.ts b/examples/demos/index.ts index 049c11c823..dae549e77b 100644 --- a/examples/demos/index.ts +++ b/examples/demos/index.ts @@ -62,19 +62,3 @@ export default [ demos: CanvasDemos, }, ]; - -export const MapType = [ - 'Map', - 'GaodeMap', - 'BaiduMap', - 'MapLibre', - 'TencentMap', - 'Mapbox', - 'TMap', - 'GoogleMap', -]; -export const InitMapOptions = { - map: 'Map', - renderer: 'device', - animate: false, -}; diff --git a/examples/demos/point/fill.ts b/examples/demos/point/fill.ts index 44bf8a60d3..3043ba8136 100644 --- a/examples/demos/point/fill.ts +++ b/examples/demos/point/fill.ts @@ -1,11 +1,12 @@ import { PointLayer, Scene } from '@antv/l7'; import * as allMap from '@antv/l7-maps'; +import type { RenderDemoOptions } from '../../types'; -export function MapRender(option: { map: string; renderer: string }) { +export function MapRender(options: RenderDemoOptions) { const scene = new Scene({ id: 'map', - renderer: option.renderer, - map: new allMap[option.map || 'Map']({ + renderer: options.renderer, + map: new allMap[options.map]({ style: 'light', center: [121.435159, 31.256971], zoom: 14.89, @@ -13,9 +14,7 @@ export function MapRender(option: { map: string; renderer: string }) { }), }); scene.on('loaded', () => { - fetch( - 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json', - ) + fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json') .then((res) => res.json()) .then((data) => { const pointLayer = new PointLayer({}) @@ -40,13 +39,7 @@ export function MapRender(option: { map: string; renderer: string }) { .size('unit_price', [10, 25]) .active(false) .select(true) - .color('name', [ - '#5B8FF9', - '#5CCEA1', - '#5D7092', - '#F6BD16', - '#E86452', - ]) + .color('name', ['#5B8FF9', '#5CCEA1', '#5D7092', '#F6BD16', '#E86452']) .style({ opacity: 1, strokeWidth: 2, diff --git a/examples/demos/template.ts b/examples/demos/template.ts index 827b0d06af..4b47bc4e0d 100644 --- a/examples/demos/template.ts +++ b/examples/demos/template.ts @@ -1,11 +1,12 @@ import { Scene } from '@antv/l7'; import * as allMap from '@antv/l7-maps'; +import type { RenderDemoOptions } from '../types'; -export function MapRender(option: { map: string; renderer: 'regl' | 'device' }) { +export function MapRender(options: RenderDemoOptions) { const scene = new Scene({ id: 'map', - renderer: option.renderer, - map: new allMap[option.map || 'Map']({ + renderer: options.renderer, + map: new allMap[options.map]({ style: 'light', center: [121.434765, 31.256735], zoom: 14.83, diff --git a/examples/template.ts b/examples/template.ts deleted file mode 100644 index 9685695e36..0000000000 --- a/examples/template.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Scene } from '@antv/l7'; -import * as allMap from '@antv/l7-maps'; - -export function MapRender(option: { - map: string - renderer: 'regl' | 'device' -}) { - - new Scene({ - id: 'map', - renderer: option.renderer, - map: new allMap[option.map || 'Map']({ - style: 'light', - center: [121.434765, 31.256735], - zoom: 14.83 - }) - }); - -} diff --git a/examples/types.ts b/examples/types.ts new file mode 100644 index 0000000000..6c3ff45f5e --- /dev/null +++ b/examples/types.ts @@ -0,0 +1,17 @@ +import type { ISceneConfig } from '@antv/l7-core'; + +export type RenderDemoMap = + | 'Map' + | 'GaodeMap' + | 'BaiduMap' + | 'MapLibre' + | 'TencentMap' + | 'Mapbox' + | 'TMap' + | 'GoogleMap'; + +export type RenderDemoOptions = { + map: RenderDemoMap; + renderer: ISceneConfig['renderer']; + animate: boolean; +}; diff --git a/examples/view.tsx b/examples/view.tsx index ed0a5162ec..e036ab03e7 100644 --- a/examples/view.tsx +++ b/examples/view.tsx @@ -2,7 +2,8 @@ import { Cascader } from 'antd'; import 'antd/dist/antd.css'; import GUI from 'lil-gui'; import React, { useEffect, useState } from 'react'; -import DemoList, { InitMapOptions, MapType } from './demos'; +import { DEFAULT_RENDER_OPTIONS, MAP_TYPES } from './constants'; +import DemoList from './demos'; import { MapView } from './view/map'; export default () => { @@ -12,7 +13,7 @@ export default () => { ? ['Point', 'fill'] : [searchParams.get('type'), searchParams.get('name')]; const [values, setValue] = useState(initState); - const [mapOption, setMapOption] = useState(InitMapOptions); + const [mapOption, setMapOption] = useState(DEFAULT_RENDER_OPTIONS); const onGUIChange = (object: any) => { setMapOption({ ...object }); }; @@ -23,7 +24,7 @@ export default () => { renderer: 'device', animate: false, }; - gui.add(option, 'map', MapType); + gui.add(option, 'map', MAP_TYPES); gui.add(option, 'renderer', ['regl', 'device']); gui.add(option, 'animate'); gui.onChange((event) => { diff --git a/jest.config.ts b/jest.config.ts index 24e5826d9e..52e71b201c 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -34,13 +34,13 @@ const config: Config = { '/__tests__/unit/*.spec.+(ts|tsx|js)', '/__tests__/unit/**/*/*.spec.+(ts|tsx|js)', ], - coveragePathIgnorePatterns: ['/node_modules/', '/iconfont/'], + coveragePathIgnorePatterns: ['/node_modules/', '/iconfont/', '/__test__/'], coverageDirectory: 'coverage', coverageReporters: ['html', 'lcov', 'clover'], coverageThreshold: { global: { branches: 30, - functions: 42, + functions: 40, lines: 50, statements: 50, }, diff --git a/packages/component/__tests__/swipe.spec.ts b/packages/component/__tests__/swipe.spec.ts new file mode 100644 index 0000000000..02bb41f1a9 --- /dev/null +++ b/packages/component/__tests__/swipe.spec.ts @@ -0,0 +1,17 @@ +import { TestScene } from '@antv/l7-test-utils'; +import Swipe from '../src/control/swipe'; + +describe('swipe', () => { + const scene = TestScene(); + + it('life cycle', () => { + const swipe = new Swipe(); + scene.addControl(swipe); + + const container = swipe.getContainer(); + expect(container.parentElement).toBeInstanceOf(HTMLElement); + + scene.removeControl(swipe); + expect(container.parentElement).not.toBeInstanceOf(HTMLElement); + }); +}); diff --git a/packages/core/src/services/layer/LayerService.ts b/packages/core/src/services/layer/LayerService.ts index dd3d72aeec..a0e1d91e61 100644 --- a/packages/core/src/services/layer/LayerService.ts +++ b/packages/core/src/services/layer/LayerService.ts @@ -6,10 +6,7 @@ import type { ILayer, ILayerService, LayerServiceEvent } from './ILayerService'; import { MaskOperation, StencilType } from './ILayerService'; const { throttle } = lodashUtil; -export default class LayerService - extends EventEmitter - implements ILayerService -{ +export default class LayerService extends EventEmitter implements ILayerService { // pickedLayerId 参数用于指定当前存在被选中的 layer public pickedLayerId: number = -1; public clock = new Clock(); @@ -107,14 +104,15 @@ export default class LayerService public async remove(layer: ILayer, parentLayer?: ILayer): Promise { // Tip: layer.layerChildren 当 layer 存在子图层的情况 if (parentLayer) { - const layerIndex = parentLayer.layerChildren.indexOf(layer); + const layerChildren = parentLayer.layerChildren; + const layerIndex = layerChildren.indexOf(layer); if (layerIndex > -1) { - parentLayer.layerChildren.splice(layerIndex, 1); + parentLayer.layerChildren = layerChildren.slice().splice(layerIndex, 1); } } else { const layerIndex = this.layers.indexOf(layer); if (layerIndex > -1) { - this.layers.splice(layerIndex, 1); + this.layers = this.layers.slice().splice(layerIndex, 1); } } layer.destroy(); @@ -171,8 +169,7 @@ export default class LayerService depth: 1, framebuffer: null, }); - const stencilType = - masks.length > 1 ? StencilType.MULTIPLE : StencilType.SINGLE; + const stencilType = masks.length > 1 ? StencilType.MULTIPLE : StencilType.SINGLE; for (const layer of masks) { // 清除上一次的模版缓存 layer.render({ isStencil: true, stencilType, stencilIndex: maskIndex++ }); @@ -192,8 +189,7 @@ export default class LayerService const masklayers = layer.masks.filter((m) => m.inited); maskCount = maskCount + (enableMask ? masklayers.length : 1); - const stencilType = - maskCount > 1 ? StencilType.MULTIPLE : StencilType.SINGLE; + const stencilType = maskCount > 1 ? StencilType.MULTIPLE : StencilType.SINGLE; // 兼容MaskLayer MaskLayer的掩膜不能clear if (layer.tileMask || (masklayers.length && enableMask)) { this.renderService.clear({ @@ -289,12 +285,7 @@ export default class LayerService } public clear() { - const color = rgb2arr(this.mapService.bgColor) as [ - number, - number, - number, - number, - ]; + const color = rgb2arr(this.mapService.bgColor) as [number, number, number, number]; this.renderService.clear({ color, depth: 1, @@ -305,9 +296,7 @@ export default class LayerService private runRender() { this.renderLayers(); - this.layerRenderID = window.requestAnimationFrame( - this.runRender.bind(this), - ); + this.layerRenderID = window.requestAnimationFrame(this.runRender.bind(this)); } private stopRender() { diff --git a/packages/layers/__tests__/tile/tile.spec.ts b/packages/layers/__tests__/tile/raster-tile.spec.ts similarity index 83% rename from packages/layers/__tests__/tile/tile.spec.ts rename to packages/layers/__tests__/tile/raster-tile.spec.ts index 2421bb9739..0d808c1964 100644 --- a/packages/layers/__tests__/tile/tile.spec.ts +++ b/packages/layers/__tests__/tile/raster-tile.spec.ts @@ -1,12 +1,12 @@ +import type { Scene } from '@antv/l7-scene'; import { TestScene } from '@antv/l7-test-utils'; import RasterLayer from '../../src/raster/index'; -describe('RasterLayer', () => { - let scene: any; +describe('raster-tile', () => { + let scene: Scene; beforeEach(() => { scene = TestScene(); }); - // vector data it('rasterLayer raster', async () => { const url1 = 'https://tiles{1-3}.geovisearth.com/base/v1/ter/{z}/{x}/{y}?format=webp&tmsIds=w&token=b2a0cfc132cd60b61391b9dd63c15711eadb9b38a9943e3f98160d5710aef788'; @@ -21,5 +21,6 @@ describe('RasterLayer', () => { }); scene.addLayer(layer1); + scene.setZoom(12); }); }); diff --git a/packages/layers/__tests__/tile/vector-tile.spec.ts b/packages/layers/__tests__/tile/vector-tile.spec.ts new file mode 100644 index 0000000000..cc7c141185 --- /dev/null +++ b/packages/layers/__tests__/tile/vector-tile.spec.ts @@ -0,0 +1,31 @@ +import { TestScene } from '@antv/l7-test-utils'; +import PointLayer from '../../src/point'; + +describe('vector-tile', () => { + let scene: any; + beforeEach(() => { + scene = TestScene(); + }); + it('pointLayer vector', async () => { + const layer = new PointLayer({ + featureId: 'COLOR', + sourceLayer: 'ecoregions2', + }); + layer + .source('https://ganos.oss-cn-hangzhou.aliyuncs.com/m2/rs_l7/{z}/{x}/{y}.pbf', { + parser: { + type: 'mvt', + tileSize: 256, + zoomOffset: 0, + maxZoom: 9, + extent: [-180, -85.051129, 179, 85.051129], + }, + }) + .shape('circle') + .color('COLOR') + .size(10); + + scene.addLayer(layer); + scene.setZoom(12); + }); +});