-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
724 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { LineLayer, Source } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const amapData: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
center: [121.434765, 31.256735], | ||
zoom: 14.83, | ||
maxZoom: 25, | ||
}, | ||
}); | ||
|
||
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.addLayer(layer); | ||
|
||
return scene; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { amapData } from './amap-data'; | ||
export { wgs84Data } from './wgs84-data'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { LineLayer, Source } from '@antv/l7'; | ||
import type { Map } from 'maplibre-gl'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const wgs84Data: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
center: [121.434765, 31.256735], | ||
zoom: 14.83, | ||
maxZoom: 23.9, | ||
}, | ||
}); | ||
|
||
const geoData = { | ||
type: 'FeatureCollection', | ||
features: [ | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'LineString', | ||
coordinates: [ | ||
[120.10121458655186, 30.269329295915544], | ||
[120.10122467185921, 30.2693341645727], | ||
[120.10123176240315, 30.269323019911795], | ||
], | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
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.addLayer(layer); | ||
|
||
if (scene.getType() === 'mapbox') { | ||
const baseMap = scene.map as Map; | ||
baseMap.on('load', () => { | ||
baseMap.addSource('route', { | ||
type: 'geojson', | ||
data: geoData, | ||
}); | ||
baseMap.addLayer({ | ||
id: 'route', | ||
type: 'line', | ||
source: 'route', | ||
layout: { | ||
'line-join': 'round', | ||
'line-cap': 'round', | ||
}, | ||
paint: { | ||
'line-color': '#0083FE', | ||
'line-width': 2, | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
return scene; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { TestCase } from '../types'; | ||
import * as BasemapTestCases from './basemap'; | ||
import * as PointTestCases from './point'; | ||
|
||
export { PointTestCases }; | ||
|
||
export const TestCases = new Map<string, [string, TestCase][]>([ | ||
['point', Object.entries(PointTestCases)], | ||
['basemap', Object.entries(BasemapTestCases)], | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { PointLayer } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const billboard: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
center: [120.188193, 30.292542], | ||
pitch: 0, | ||
zoom: 16, | ||
}, | ||
}); | ||
|
||
const layer = new PointLayer() | ||
.source({ | ||
type: 'FeatureCollection', | ||
features: [ | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [120.188193, 30.292542], | ||
}, | ||
}, | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [120.201665, 30.26873], | ||
}, | ||
}, | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [120.225209, 30.290802], | ||
}, | ||
}, | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [120.189641, 30.293248], | ||
}, | ||
}, | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [120.189389, 30.292542], | ||
}, | ||
}, | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [120.190837, 30.293303], | ||
}, | ||
}, | ||
], | ||
}) | ||
.size(10) | ||
.color('#f00') | ||
.shape('simple'); | ||
|
||
scene.addLayer(layer); | ||
|
||
return scene; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { PointLayer } from '@antv/l7'; | ||
import data from '../../data/shanghaixi-village.json'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const column: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
style: 'light', | ||
center: [121.400257, 31.25287], | ||
zoom: 14.55, | ||
pitch: 45, | ||
}, | ||
}); | ||
|
||
const pointLayer = new PointLayer({}) | ||
.source(data, { | ||
parser: { | ||
type: 'json', | ||
x: 'longitude', | ||
y: 'latitude', | ||
}, | ||
}) | ||
.shape('name', ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn']) | ||
.active(true) | ||
.size('unit_price', (h) => { | ||
return [6, 6, 100]; | ||
}) | ||
.color('name', ['#739DFF', '#61FCBF', '#FFDE74', '#FF896F']) | ||
.style({ | ||
opacity: 1, | ||
}); | ||
|
||
scene.addLayer(pointLayer); | ||
|
||
return scene; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { PointLayer } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const dot: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
center: [116.417463, 40.015175], | ||
zoom: 8, | ||
minZoom: 5, | ||
}, | ||
}); | ||
|
||
const data = await fetch( | ||
'https://gw.alipayobjects.com/os/antfincdn/8Ps2h%24qgmk/traffic_110000.csv', | ||
).then((res) => res.text()); | ||
|
||
const colors = ['#c57f34', '#cbfddf', '#edea70', '#8cc9f1', '#2c7bb6']; | ||
const pointLayer = new PointLayer({}) | ||
.source(data, { | ||
parser: { | ||
type: 'csv', | ||
y: 'lat', | ||
x: 'lng', | ||
}, | ||
}) | ||
.shape('dot') | ||
.size(0.5) | ||
.color('type', (type) => { | ||
switch (parseInt(type)) { | ||
case 3: | ||
return colors[0]; | ||
case 4: | ||
return colors[1]; | ||
case 41: | ||
return colors[2]; | ||
case 5: | ||
return colors[3]; | ||
default: | ||
return colors[4]; | ||
} | ||
}); | ||
|
||
scene.addLayer(pointLayer); | ||
|
||
return scene; | ||
}; |
Oops, something went wrong.