cesium 读取json
来源:互联网 发布:电子键盘软件 编辑:程序博客网 时间:2024/06/05 17:36
初识cesium----加载不同JSON格式例子
最近研究了几天cesium.js,有些入门级的收获,随手记录下来,方便以后来查阅!
cesium支持topojson,GEOjson和普通的json格式,下面展示三种不同的格式的例子
一、topojson
<body> <div id="cesiumContainer"></div> <script> //加载topojson var viewer = new Cesium.Viewer('cesiumContainer'); var promise= viewer.dataSources.add(Cesium.GeoJsonDataSource.load('../../Apps/china.topojson', { stroke: Cesium.Color.BLACK, fill: Cesium.Color.RED, strokeWidth: 3, markerSymbol: '?' })); viewer.flyTo(promise); </script></body>
二、GEOjson
<body> <div id="cesiumContainer"></div> <script> var viewer = new Cesium.Viewer('cesiumContainer'); //Seed the random number generator for repeatable results. Cesium.Math.setRandomNumberSeed(0); var promise=Cesium.GeoJsonDataSource.load('../../Apps/testone.json'); promise.then(function(dataSource) { viewer.dataSources.add(dataSource); var entities = dataSource.entities.values; var colorHash = {}; 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 : 1.0 }); colorHash[name] = color; } entity.polygon.material = color; entity.polygon.outline = false; entity.polygon.extrudedHeight =5000.0; } }); viewer.flyTo(promise); </script></body>
三、普通json
<body> <div id="cesiumContainer"></div> <script> var viewer = new Cesium.Viewer('cesiumContainer'); Cesium.Math.setRandomNumberSeed(0); Cesium.loadJson('/../Apps/Points.json').then(function(jsonData) { for (var i =0 ;i<=jsonData.features.length-10; i++) { var ifeature=jsonData.features[i]; for (var k = 0;k<ifeature.geometry.paths[0].length-10; k++) { if (ifeature.geometry.paths[0][k].length==2) { viewer.entities.add({ position : Cesium.Cartesian3.fromDegrees(ifeature.geometry.paths[0][k][0],ifeature.geometry.paths[0][k][1]), point : { pixelSize : 10, color :Cesium.Color.YELLOW } }); } } } }).otherwise(function(error) {}); </script></body>
阅读全文
0 0
- cesium 读取json
- Cesium
- Cesium 坐标系的转换+shp转Json工具
- Json 读取
- 读取Json
- json读取
- 读取json
- 读取json
- 读取json 读取本地文件
- Cesium学习(二)shp格式转为json格式(一)
- Cesium学习(二)shp格式转为json格式并叠加到底图上使用
- Cesium ArcGisImageServerTerrainProvider
- Cesium ArcGisMapServerImageryProvider
- Cesium AxisAlignedBoundingBox
- Cesium BarycentricCoordinates
- Cesium BaseLayerPicker
- Cesium BaseLayerPickerViewModel
- Cesium BillboardCollection
- floodlight安装过程总结以及错误处理方法
- 怎么把网站快速搭建起来?
- Linux 系统命令及shell脚本2
- "Illegal property type, c for appearance setter, _installAppearanceSwizzleForSetter:
- Understanding Deep Learning required Rethinking Generalization 笔记
- cesium 读取json
- HMAC-SHA1签名工具类
- 链表中倒数第k个结点
- 偏导数与全导数的关系 以及 偏微分与全微分的关系
- python之pandas分组统计
- Java并发线程池,ThreadPoolExecutor解析
- [ArcGIS] 空间分析(三)栅格数据
- 枚举的总结
- 转:正则表达式进阶(资料整理)