【问题标题】:Removing Polyline in cesium js删除铯js中的折线
【发布时间】:2015-12-24 09:33:07
【问题描述】:

如何在cesiumjs中去除折线,

var p = this.viewer.entities.add({
    polyline: {
        material: new Cesium.PolylineGlowMaterialProperty({
            glowPower: 0.7,
            color: Cesium.Color.ORANGE.withAlpha(0.7)
        }),
        positions: Cesium.Cartesian3.fromDegreesArrayHeights(points),
        width: 15,
    }
});

我使用了entities.removeAll(),但它正在从铯容器中删除整个数据(包括模型等)。我只想删除折线。

【问题讨论】:

    标签: cesium


    【解决方案1】:

    保存entities.add的返回值,这是对新创建实体的引用。

    var polylineEntity = viewer.entities.add({
        //...
    });
    

    稍后,您可以通过引用删除特定实体。

    viewer.entities.remove(polylineEntity);
    

    【讨论】:

      【解决方案2】:
      var pathDone; //Store dataSource so later can be removed.
      viewer.dataSources.remove(pathDone,true); // Removing old data.
      
      Cesium.GeoJsonDataSource.load(data, { // Data contains geojson, linestring z.
          stroke: Cesium.Color.HOTPINK,
          fill: Cesium.Color.PINK.withAlpha(0.5),
          strokeWidth: 2
      }).then(function(geoData){
           viewer.dataSources.add(geoData); //Adding new one.
           pathDone=geoData;//Storing new reference.
      });
      

      这对我有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-02
        • 1970-01-01
        相关资源
        最近更新 更多