cesium 加载geoJson格式的图斑

Cesium加载geoJson 格式的图斑方法:

// 首次进来判断是否存在图斑 
if(this.geoSource) {
    this.Global.viewer.dataSources.remove(this.Global.viewer.dataSources.getByName('图斑')[0])
 }
let geoData = {
  "type": "FeatureCollection", "features": [
      { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": this.coordinates}, "properties": { "Id": 0 } }
  ]}
this.geoSource = Cesium.GeoJsonDataSource.load(geoData,{
  stroke:Cesium.Color.YELLOW,
  fill:Cesium.Color.YELLOW.withAlpha(0.5),
  strokeWidth: 8,
  clampToGround: true //是否贴地
  })
  this.geoSource.then((res) => {
  this.Global.viewer.dataSources.add(res);
  res.name = '图斑'
})

补充geoJson 可是作为示例

{type": "FeatureCollection", "features": [
      { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [
          [
            [
              114.14252662700005,
              35.68635368300005
            ],
            [
              114.14277076700012,
              35.685392380000053
            ],
            [
              114.14137077300006,
              35.685319900000025
            ],
            [
              114.14035987900002,
              35.685838699000044
            ],
            [
              114.14057350200005,
              35.686693192000064
            ],
            [
              114.14252662700005,
              35.68635368300005
            ]
          ]
        ]}, "properties": { "Id": 0 } }
 ]}

完结

posted @ 2022-11-10 16:01  color_小浣熊  阅读(828)  评论(0编辑  收藏  举报
百度