antv-l7/stories/mask/components/line.tsx

193 lines
4.5 KiB
TypeScript
Raw Normal View History

Mask (#946) * feat: 增加着色器的拾取计算控制、完善 arcmini * feat: 完善 enableShaderPick/disableShaderPick 功能 * style: lint style * feat: 补充调用高德地图公交线路查询 demo * style: lint style * feat: 优化弧线的纹理动画 * style: lint style * feat: 去除greatCircle 的纹理动画优化 * feat: 扩展点图层圆柱效果 * feat: 增加几何体的径向渐变配置 * style: lint style * fix: 修复bug 图层触发的事件跟图层设置的zIndex无关,只跟插入图层先后顺序有关 * style: lint style * feat: 补全挤出几何体拾取颜色的光照配置 * style: lint style * fix: 修复圆柱 cull 问题 mapbox amap 不同 * feat: 图层销毁时的内存泄漏 * style: lint style * feat: 平面弧线新增弧线偏移量的数据映射能力 * style: lint style * fix: 修复重复销毁bug * style: lint style * feat: 修复 texture 重复销毁问题 * style: lint style * fix: 修复图层叠加模式下的拾取失效问题 * style: lint style * fix: 修复纹理贴图在 zoom 大于 12 时存在的问题 * fix: 修复水波点颜色偏暗 * feat: 优化点图层的渲染效果,叠加渲染效果 * style: lint style * fix: 修复 layer contextmenu 事件丢失 * fix: 修复 map 类型 resize 失效 * style: lint style * feat: 增加瓦片地图的请求节流 * style: lint style * feat: 优化热力图在 radius 数值比较大时热力点边缘发生裁剪的现象 * style: lint style * fix: 修复resize 后 picking shiqu 拾取失败的问题 * feat: 优化 marker/popup 在容器边缘的表现 * feat: 增加 setEnableRender 方法 * style: lint style * feat: 增加城市图层扫光特效 * style: lint style * feat: 补全拾取色混合配置 * style: lint style * feat: 增加高德地图的面积大小点 * style: lint style * feat: 点优化边缘锯齿 * fix: 修复pointLayer stroke 变暗问题 * fix: 修复混合导致的拾取错误 * feat: add simple point 1.0 * style: lint style * feat: simple point support stroke * style: lint style * feat: 优化 simple point 边缘的锯齿 * style: lint style * feat: add point cylinder raising animate * style: lint style * feat: 优化点图层 icon 在小尺寸下的锯齿问题 * style: lint style * feat: 修复 layer destroy 报错、未清理、未重绘、补充触发 destroy 事件 * fix: 修复 marker 在 cluster getMakers 失效 * style: lint style * feat: 清除 marker layer cluster fix * style: lint style * fix: 修复 markerLayer hide show 方法缺少 cluster 模式下的控制 * style: lint style * feat: 取消在 shape 方法执行后的暴力更新 * style: lint style * feat: 增加图层保底颜色设置 * style: lint style * feat: 将兜底颜色改为 bottomColor * fix: color bottom * style: lint style * feat: 修改颜色兜底判断逻辑 * style: lint style * feat: add tnpm dist-tag * feat: 增加line border 边框 * style: lint style * feat: 增加 layer 重复销毁过滤 * style: lint style * feat: 新增 wall 图层 * style: lint style * feat: add image minimap * style: lint style * feat: 增加 pointLayer image mipmap 支持 * style: lint style * feat: 调整点图层 image size 和之前保持一致 * fix: 修复线图层在存在高度的情况下,不同地图,不同场景下的效果兼容 * style: lint style * fix: 修复线纹理在 mapbox 下表现不一致 * style: lint style * fix: 修复 threejs 图层导致 L7 图层失效的问题 * style: lint style * feat: 增加 simple line、修复 pointLayer meter 单个数据失效的情况 * style: lint style * feat: 优化 simple line 效果 * style: lint style * feat: 完善 demo * style: lint style * feat: adjust demo * style: lint style * feat: 修改简单线体层的 shape 参数 * feat: change simple lint type * feat: demo fix * style: lint style * fix: 修复聚合图在放大、缩小时计算的 data 数量不同的问题 * style: lint style * feat: demo 调整 * feat: 完善 demo * feat: 提供相机运动相关方法 0.1 * feat: 增加 mask 0.1 * style: lint style * feat: 增加 demo * style: lint style * feat: pickbox 返回值增加选中id * style: lint style * feat: 完善掩模能力 * style: lint style * feat: 完善蒙层方案 * style: lint style * feat: 增加 点图层 mask 支持 * style: lint style * feat: 图片图层支持 mask * style: lint style * feat: heatmap support mask * style: lint style * feat: rasterLayer support mask * style: lint style * feat: polygonLayer support mask * style: lint style * feat: change raster mask demo * style: lint style * feat: pointLayer text support mask * style: lint style * feat: 改变 maskLayer 的默认透明度 * style: lint style
2022-01-24 17:46:10 +08:00
import {
LineLayer,
Scene,
MaskLayer,
PolygonLayer,
PointLayer,
} from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
import * as React from 'react';
export default class Amap2demo_road2 extends React.Component {
// @ts-ignore
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
stencil: true,
map: new GaodeMap({
center: [120.165, 30.26],
pitch: 0,
zoom: 15,
viewMode: '3D',
style: 'dark',
}),
});
this.scene = scene;
const data = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'MultiPolygon',
coordinates: [
[
[
[120.16021728515624, 30.259660295442085],
[120.15987396240234, 30.25313608393673],
[120.16605377197266, 30.253729211980726],
[120.1658821105957, 30.258474107402265],
],
],
[
[
[120.1703453063965, 30.258474107402265],
[120.17086029052733, 30.254174055663515],
[120.17583847045898, 30.254915457324778],
[120.17446517944336, 30.258474107402265],
],
],
],
},
},
],
};
const data2 = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'MultiPolygon',
coordinates: [
[
[
[120.16536712646484, 30.26336704072365],
[120.16777038574219, 30.2657392842738],
[120.17086029052733, 30.26232916614846],
],
],
],
},
},
],
};
const data3 = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'MultiPolygon',
coordinates: [[]],
},
},
],
};
scene.on('loaded', () => {
const polygonlayer = new MaskLayer({})
.source(data)
.shape('fill')
.color('red')
.style({
opacity: 0.3,
});
scene.addLayer(polygonlayer);
let points = new PointLayer({ zIndex: 2, mask: true })
.source(
[
{
lng: 120.14871597290039,
lat: 30.268407989758884,
},
{
lng: 120.15352249145508,
lat: 30.271669642392517,
},
{
lng: 120.16502380371092,
lat: 30.26944580007901,
},
{
lng: 120.16485214233397,
lat: 30.26425663877134,
},
{
lng: 120.16073226928711,
lat: 30.259067203213018,
},
],
{
parser: {
type: 'json',
x: 'lng',
y: 'lat',
},
},
)
.shape('circle')
.size(25)
.color('#0ff')
.style({
opacity: 0.3,
});
scene.addLayer(points);
fetch(
'https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json',
)
.then((res) => res.json())
.then((data) => {
// const layer = new LineLayer({ mask: true, maskInside: false }) // mask: true maskInside: true
const layer = new LineLayer({ mask: true, maskInside: true }) // mask: true maskInside: true
.source(data)
.size(5)
.shape('arc3d') // line arc greatcircle simple
.color('rgb(20, 180, 90)')
.style({
borderWidth: 0.35,
borderColor: '#fff',
})
.active(true);
scene.addLayer(layer);
const polygonlayer2 = new MaskLayer({})
.source(data2)
.shape('fill')
.color('#ff0')
.style({
opacity: 0.3,
});
scene.addLayer(polygonlayer2);
});
});
}
public render() {
return (
<>
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
</>
);
}
}