美文网首页开源
cesium加载geojson

cesium加载geojson

作者: 清远_03d9 | 来源:发表于2019-10-23 00:43 被阅读0次

    1. 数据加载

     showRegionExtent: function (feature) {
            var that = this; 
            var dataSource = Cesium.GeoJsonDataSource.load(feature, {
                clampToGround: true,
                stroke: new Cesium.Color.fromCssColorString("#ffffff"),
                strokeWidth: 2,
                fill: new Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.5)
            });
            dataSource.then(function (dataSource) {
                that.viewer.dataSources.add(dataSource);
                that.last_region = dataSource;
    
                that.viewer.flyTo(dataSource.entities.values, { duration: 2 });
            }).otherwise(function (error) {
                toastr.error(error);
            });
       
        },
    

    2. 数据删除

    //显示行政区划边界
        last_region: null,
        clearLastRegion: function () {
            if (this.last_region != null) {
                this.viewer.dataSources.remove(this.last_region);
                this.last_region = null;
            }
            if (this.last_timetemp != -1) {
                clearTimeout(this.last_timetemp);
                this.last_timetemp = -1;
            }
        },
    

    相关文章

      网友评论

        本文标题:cesium加载geojson

        本文链接:https://www.haomeiwen.com/subject/gzncvctx.html