Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 重构高德地图 V2 以视口进行同步 #2387

Merged
merged 26 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ jobs:
# use xvfb-run run in ubuntu
run: xvfb-run pnpm test-cover

- name: Upload test coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# - name: Upload test coverage
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}

integration-test:
runs-on: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions __tests__/integration/heatmap.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { generateCanvasTestCases } from './utils/generator';

const TEST_CASES = [
{
name: 'normal',
sleepTime: 1000,
},
{
name: 'grid',
snapshots: false,
},
{
name: 'hexagon',
snapshots: false,
},
];

describe('Heatmap Snapshot', () => {
generateCanvasTestCases('Heatmap', TEST_CASES);
});
9 changes: 4 additions & 5 deletions __tests__/integration/line.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ const TEST_CASES = [
name: 'arc_plane',
sleepTime: 500,
},

{
name: 'flow',
sleepTime: 800,
},
{
name: 'arc',
sleepTime: 600,
Expand All @@ -22,6 +17,10 @@ const TEST_CASES = [
name: 'dash',
sleepTime: 500,
},
{
name: 'flow',
sleepTime: 1000,
},
];

describe('Line Snapshot', () => {
Expand Down
1 change: 1 addition & 0 deletions __tests__/integration/point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TEST_CASES = [
},
{
name: 'column',
sleepTime: 200,
},
{
name: 'fill_image',
Expand Down
1 change: 1 addition & 0 deletions __tests__/integration/polygon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { generateCanvasTestCases } from './utils/generator';
const TEST_CASES = [
{
name: 'extrude',
sleepTime: 200,
},
{
name: 'fill',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Polygon_extrude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { RenderDemoMap, RenderDemoOptions } from './types';
export const MAP_TYPES: RenderDemoMap[] = [
'Map',
'GaodeMap',
'GaodeMapNext',
'BaiduMap',
'MapLibre',
'TencentMap',
Expand Down
46 changes: 46 additions & 0 deletions examples/demos/basemap/amap-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { LineLayer, Scene, Source } from '@antv/l7';
import * as allMap from '@antv/l7-maps';
import type { RenderDemoOptions } from '../../types';

export function MapRender(options: RenderDemoOptions) {
const scene = new Scene({
id: 'map',
renderer: options.renderer,
map: new allMap[options.map]({
style: 'normal',
center: [121.434765, 31.256735],
zoom: 14.83,
}),
});
const geoData = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: [
[120.104021, 30.262493],
[120.103875, 30.262601],
[120.103963, 30.262694],
],
},
},
],
};

const source = new Source(geoData);
const layer = new LineLayer({ blend: 'normal', autoFit: true })
.source(source)
.size(2)
.shape('line')
.color('#f00')
.style({
opacity: 1,
});

scene.on('loaded', () => {
scene.addLayer(layer);
});
}
1 change: 1 addition & 0 deletions examples/demos/basemap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MapRender as amapData } from './amap-data';
40 changes: 40 additions & 0 deletions examples/demos/bugfix/data-shake.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { PointLayer, Scene } from '@antv/l7';
import * as allMap from '@antv/l7-maps';
import { featureEach, interpolate, randomPoint } from '@turf/turf';
import type { RenderDemoOptions } from '../../types';

const points = randomPoint(30, { bbox: [120.103217, 30.26128, 120.10348, 30.261506] });

featureEach(points, function (point) {
// add a random property to each point
point.properties.solRad = Math.random() * 50;
});

const GEO_DATA = interpolate(points, 0.001, {
gridType: 'point',
property: 'solRad',
units: 'miles',
});

export function MapRender(options: RenderDemoOptions) {
const scene = new Scene({
id: 'map',
renderer: options.renderer,
map: new allMap[options.map]({
style: 'normal',
center: [121.434765, 31.256735],
zoom: 14.83,
maxZoom: 23,
}),
});

const layer = new PointLayer({ autoFit: true })
.source(GEO_DATA)
.size(10)
.color('#f00')
.shape('simple');

scene.on('loaded', () => {
scene.addLayer(layer);
});
}
1 change: 1 addition & 0 deletions examples/demos/bugfix/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { MapRender as color } from './color';
export { MapRender as data_shake } from './data-shake';
export { MapRender as event_legend } from './event_legend';
export { MapRender as polygon } from './polygon';
export { MapRender as remove_muti_layer } from './remove-muti-layer';
Expand Down
5 changes: 5 additions & 0 deletions examples/demos/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as BaseMapDemos from './basemap';
import * as BugFix from './bugfix';
import * as CanvasDemos from './canvas';
import * as Components from './components';
Expand Down Expand Up @@ -61,4 +62,8 @@ export default [
name: 'Canvas',
demos: CanvasDemos,
},
{
name: 'BaseMap',
demos: BaseMapDemos,
},
];
1 change: 1 addition & 0 deletions examples/demos/polygon/extrude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function MapRender(options: RenderDemoOptions) {
style: 'light',
center: [121.434765, 31.256735],
zoom: 14.83,
pitch: 45,
}),
});

Expand Down
1 change: 1 addition & 0 deletions examples/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ISceneConfig } from '@antv/l7-core';
export type RenderDemoMap =
| 'Map'
| 'GaodeMap'
| 'GaodeMapNext'
| 'BaiduMap'
| 'MapLibre'
| 'TencentMap'
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/core/BaseLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
}

protected get mapService() {
return this.container.mapService;
return this.container?.mapService;
}

public styleAttributeService: IStyleAttributeService;
Expand Down
8 changes: 8 additions & 0 deletions packages/maps/src/amap-next/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import BaseMapWrapper from '../utils/BaseMapWrapper';
import MapService from './map';

export default class AMap2Wrapper extends BaseMapWrapper<AMap.Map> {
protected getServiceConstructor() {
return MapService;
}
}
9 changes: 9 additions & 0 deletions packages/maps/src/amap-next/logo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.amap-logo {
display: none !important;
}
.amap-copyright {
display: none !important;
}
.amap-overlays {
z-index: 3 !important;
}
Loading
Loading