style: lint style

This commit is contained in:
2912401452 2022-03-25 22:14:40 +08:00
parent 1b59b6f59b
commit e666c043e7
3 changed files with 63 additions and 53 deletions

View File

@ -12,6 +12,7 @@ PlaneGeometry 是 L7 提供的通用的平面几何体图形,表现为可以
### 基本用法
设置普通矩形
```javascript
import { Scene, GeometryLayer } from '@antv/l7';
@ -25,7 +26,7 @@ const layer = new GeometryLayer()
})
.active(true)
.color('#ff0');
scene.addLayer(layer);
scene.addLayer(layer);
```
<img width="60%" style="display: block;margin: 0 auto;" alt="案例" src='https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*7DpqRrE0LM4AAAAAAAAAAAAAARQnAQ'>
@ -37,29 +38,27 @@ const layer = new GeometryLayer()
```javascript
import { Scene, GeometryLayer } from '@antv/l7';
const layer = new GeometryLayer()
.shape('plane')
.style({
width: 0.074,
height: 0.061,
center: [120.1025, 30.2594],
widthSegments: 200,
heightSegments: 200,
terrainClipHeight: 1,
mapTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*gA0NRbuOF5cAAAAAAAAAAAAAARQnAQ',
terrainTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*eYFaRYlnnOUAAAAAAAAAAAAAARQnAQ',
rgb2height: (r, g, b) => {
let h =
-10000.0 +
(r * 255.0 * 256.0 * 256.0 + g * 255.0 * 256.0 + b * 255.0) * 0.1;
h = h / 20 - 127600;
h = Math.max(0, h);
return h;
},
});
scene.addLayer(layer);
const layer = new GeometryLayer().shape('plane').style({
width: 0.074,
height: 0.061,
center: [120.1025, 30.2594],
widthSegments: 200,
heightSegments: 200,
terrainClipHeight: 1,
mapTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*gA0NRbuOF5cAAAAAAAAAAAAAARQnAQ',
terrainTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*eYFaRYlnnOUAAAAAAAAAAAAAARQnAQ',
rgb2height: (r, g, b) => {
let h =
-10000.0 +
(r * 255.0 * 256.0 * 256.0 + g * 255.0 * 256.0 + b * 255.0) * 0.1;
h = h / 20 - 127600;
h = Math.max(0, h);
return h;
},
});
scene.addLayer(layer);
```
<img width="60%" style="display: block;margin: 0 auto;" alt="案例" src='https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*mkPtQJVN8eQAAAAAAAAAAAAAARQnAQ'>
@ -67,38 +66,49 @@ import { Scene, GeometryLayer } from '@antv/l7';
[在线案例](/zh/examples/geometry/geometry#terrain)
### source
🌟 PlaneGeometry 不需要设置 source我们在 style 中通过 center 赋予其位置信息。
### style
PlaneGeometry 主要通过 style 方法设置位置、大小以及其他属性。
#### center: [lng: number, lat: number]
设置 PlaneGeometry 的位置,定位是 PlaneGeometry 的几何中心。PlaneGeometry 贴地放置。
#### width: number
设置 PlaneGeometry 的宽度,单位是经度。
#### height: number
设置 PlaneGeometry 的高度,单位是纬度。
#### widthSegments: number
设置 PlaneGeometry 在 纬度方向上的分段数。
#### heightSegments: number
设置 PlaneGeometry 在 经度方向上的分段数。
#### mapTexture: string
PlaneGeometry 纹理贴图 URL。
#### terrainTexture: string
PlaneGeometry 高度贴图 URL当存在该参数的时候 L7 会自动解析高程信息。
#### terrainClipHeight: number
指定 3D 地形的裁剪高度。在一些情况下我们可能只需要保留存在丘陵山地的部分,通过这个参数我们可以指定地形高度低于这个参数值的部分不显示.
<img width="60%" style="display: block;margin: 0 auto;" alt="案例" src='https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*-SpgT6R05bcAAAAAAAAAAAAAARQnAQ'>
#### rgb2height: (r: number, g: number, b: number) => number
这是一个回调函数,参数是 L7 解析出的地形贴图的 rgb 信息,用户可以使用该函数定义高度值的计算逻辑(不同的地形贴图计算逻辑不同)。
🌟 widthSegments/heightSegments 指定 planeGeometry 的分段数,分段越多,地形越平滑,同时性能消耗越大。

View File

@ -4,7 +4,7 @@ import { GaodeMap } from '@antv/l7-maps';
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [120.1025, 30.2594],
center: [ 120.1025, 30.2594 ],
style: 'dark',
zoom: 10
})
@ -12,14 +12,14 @@ const scene = new Scene({
scene.on('loaded', () => {
const layer = new GeometryLayer()
.shape('plane')
.style({
opacity: 0.8,
width: 0.074,
height: 0.061,
center: [120.1025, 30.2594],
})
.active(true)
.color('#ff0');
.shape('plane')
.style({
opacity: 0.8,
width: 0.074,
height: 0.061,
center: [ 120.1025, 30.2594 ]
})
.active(true)
.color('#ff0');
scene.addLayer(layer);
});

View File

@ -4,36 +4,36 @@ import { GaodeMap } from '@antv/l7-maps';
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [120.1025, 30.2594],
center: [ 120.1025, 30.2594 ],
style: 'dark',
pitch: 65,
rotation: 180,
zoom: 14,
zoom: 14
})
});
scene.on('loaded', () => {
const layer = new GeometryLayer()
.shape('plane')
.style({
width: 0.074,
height: 0.061,
center: [120.1025, 30.2594],
widthSegments: 200,
heightSegments: 200,
terrainClipHeight: 1,
mapTexture:
.shape('plane')
.style({
width: 0.074,
height: 0.061,
center: [ 120.1025, 30.2594 ],
widthSegments: 200,
heightSegments: 200,
terrainClipHeight: 1,
mapTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*gA0NRbuOF5cAAAAAAAAAAAAAARQnAQ',
terrainTexture:
terrainTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*eYFaRYlnnOUAAAAAAAAAAAAAARQnAQ',
rgb2height: (r, g, b) => {
let h =
rgb2height: (r, g, b) => {
let h =
-10000.0 +
(r * 255.0 * 256.0 * 256.0 + g * 255.0 * 256.0 + b * 255.0) * 0.1;
h = h / 20 - 127600;
h = Math.max(0, h);
return h;
},
});
h = h / 20 - 127600;
h = Math.max(0, h);
return h;
}
});
scene.addLayer(layer);
});