Преглед на файлове

add graticule layer

tags/3.0.0
Caven Chen преди 2 години
родител
ревизия
c29b7dd84e
променени са 1 файла, в които са добавени 78 реда и са изтрити 0 реда
  1. 78
    0
      modules/layer/type/GraticuleLayer.js

+ 78
- 0
modules/layer/type/GraticuleLayer.js Целия файл

@@ -0,0 +1,78 @@
/**
@Author: Caven Chen
@Date: 2023-01-12
**/

import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Layer from '../Layer'

const DEF_OPTS = {
radialColor: Cesium.Color.WHITE,
radialWidth: 2,
showRadial: true,
LableColor: Cesium.Color.YELLOW,
weftColor: Cesium.Color.WHITE,
weftWidth: 2
}

class GraticuleLayer extends Layer {
constructor(id, options) {
super(id)
this._options = {
...DEF_OPTS,
...options
}
this._delegate = new Cesium.CustomDataSource(id)
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('graticule')
}

_addedHook() {
for (let i = 0; i < 36; i++) {
this._delegate.entities.add({
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray([
i * 10,
89.5,
i * 10,
-89.5
]),
material: this._options.radialColor,
width: this._options.radialWidth
},
show: this._options.showRadial
})

this._delegate.entities.add({
position: Cesium.Cartesian3.fromDegrees(i * 10, 0.0),
label: {
text: i * 10 + '°',
font: '12px',
fillColor: this._options.LableColor
}
})
}

for (let i = 0; i < 18; i++) {
let coords = []
for (let k = 0; k < 129; k++) {
coords.push(-180 + k * (360 / 128), (i < 9 ? i : -i) * 10)
}
this._delegate.entities.add({
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray(coords),
material: this._options.weftColor,
width: this._options.weftWidth
}
})
}
}
}

Layer.registerType('graticule')

export default GraticuleLayer

Loading…
Отказ
Запис