学习cesium,关于图层界面的切换
2019-08-14 10:20:00来源:博客园 阅读 ()
最近学习cesium的3D引擎,有关图层切换的例子比较少,在官网上看见了一些例子加以自己的理解。投机了一种近似于图层切换的效果。
这种图层切换每次点击按钮时,会把其他的数据和实体给删除。然后再创建或加载一个新的
闲话不多说我们直接上代码
Sandcastle.addToolbarButton('Basic styling', function() {
viewer.dataSources.add(Cesium.GeoJsonDataSource.load(URL, {
stroke: Cesium.Color.HOTPINK,
fill: Cesium.Color.PINK.withAlpha(0.5),
strokeWidth: 3
}));
});
Sandcastle.addToolbarButton('按钮',function() {
var position = Cesium.Cartesian3.fromDegrees(116.39053344726561,39.89604077881996, 0.0);
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(135), 0.0, 0.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
var model = viewer.entities.add({
id:'01',
position : position,
orientation : orientation,
model : {
uri : URL,
minimumPixelSize : 128,
maximumScale : 20000
}
});
},"toolbar");
Sandcastle.reset = function() {
viewer.dataSources.removeAll();
viewer.entities.removeById('01')//根据id删除entity
//设置相机为home为起点
viewer.camera.lookAt(Cesium.Cartesian3.fromDegrees(116.39053344726561,39.89604077881996, 2631.082799425431), new Cesium.Cartesian3(0.0, -4790.0, 3930.0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
};
//Sandcastle_End
Sandcastle.finishedLoading();
原文链接:https://www.cnblogs.com/xiada-zhihua/p/11259958.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- 关于jQuery UI 使用心得及技巧 2020-03-29
- 如何用javascript连接access数据库 2020-03-20
- javascript 中关于array的常用方法详解 2020-03-16
- 关于JS array的数组 2020-03-08
- 在JavaScript中尽可能使用局部变量的原因 2020-03-08
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
