XbsjEarthUI icon indicating copy to clipboard operation
XbsjEarthUI copied to clipboard

EarthSDK可以类似cesium加载点那种 建立一个父实体集来控制显示隐藏

Open vtxf opened this issue 4 years ago • 1 comments

var p = new XE.Obj.Pin(uia.earth); var p2 = new XE.Obj.Pin(uia.earth); p.position = [1.9748895674441815, 0.5216586947793432, 0] p2.position = [1.9574436561344333, 0.5166830769150111, 0]; var g = new XE.SceneTree.Group(uia.earth) g.children.push(new XE.SceneTree.Leaf(p)); g.children.push(new XE.SceneTree.Leaf(p2)); uia.earth.sceneTree.root.children.push(g)

image

vtxf avatar Dec 09 '19 02:12 vtxf

我有同样的需求,需求大概是点的管理吧 我这样解决的 给点增加一个group属性,然后用filter来筛选特定group的图钉


const data = [
    { lng: 120.1, lat: 30, height: 500, info: '数据1' },
    { lng: 120.2, lat: 30, height: 500, info: '数据2' },
    { lng: 120.3, lat: 30, height: 500, info: '数据3' },
]
// 增加图钉
data.forEach(i => {
    const objConfig = {
        "group": 'my_group_1',
        "xbsjType": "Pin",
        "position": [Cesium.Math.toRadians(i.lng), Cesium.Math.toRadians(i.lat), i.height],
        "near": 300,
    }
    let pin = new XE.Obj.Pin(earth)
    pin.xbsjFromJSON(objConfig)
})

// 移除图钉
const pins = earth.getAllObjects('Pin')
pins.filter(i => (i.group === 'my_group_1')).forEach(i => i.destroy())

HNQX avatar Oct 12 '22 03:10 HNQX