晨风のblog
首页
栏目分类
默认分类
Cesium
Vue
C#
Linux
Docker
Revit
Neo4j
Cypher
Nginx
归档
关于
归档
关于
首页
Cesium
正文
Cesium直接加载Shape文件,Js解析Shape文件库
晨风
2021-07-22 PM
459℃
0条
原仓库地址:https://github.com/calvinmetcalf/shapefile-js 使用: ```javascript var base = 'data/shp.zip'; // shp文件zip压缩包或单独的shp文件路径 shp(base).then(function (data) { var promise = Cesium.GeoJsonDataSource.load(data); promise.then(function (dataSource) { gisViewer.getViewer().dataSources.add(dataSource); var entities = dataSource.entities.values; var colorHash = {}; gisViewer.getViewer()._cesiumWidget._creditContainer.style.display = "none"; for (var i = 0; i < entities.length; i++) { var entity = entities[i]; var name = entity.name; var color = colorHash[name]; if (!color) { color = Cesium.Color.fromRandom({ alpha: 0.4 }); colorHash[name] = color; } entity.polygon.classificationType = Cesium.ClassificationType.TERRAIN; entity.polygon.material = Cesium.Color.WHITE.withAlpha(0.3); entity.polygon.outline = true; entity.polygon.outlineColor = Cesium.Color.BLUE.withAlpha(1); entity.polygon.outlineWidth = 2; entity.polygon.distanceDisplayCondition = new Cesium.DistanceDisplayCondition(3000, 10000000000); var polyPositions = entity.polygon.hierarchy.getValue(Cesium.JulianDate.now()).positions; var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter); entity.position = polyCenter; } }); ```
标签:
cesium
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:
http://blog.chenfengly.com/index.php/archives/13/
上一篇
Cesium自定义圆柱体Geomerty表面贴图
下一篇
VSCode setting.js 配置vue文件格式化
取消回复
评论啦~
提交评论
栏目分类
默认分类
5
Cesium
5
Vue
1
C#
3
Linux
4
Docker
2
Revit
1
Neo4j
0
Cypher
1
Nginx
1
标签云
elementui
cypher
SqlServer
tree
node
vue
C#
neo4j
cesium