当前位置: 首页 > news >正文

cesium案例:三维钢铁厂园区开发平台(附源码下载)

基于cesium的三维钢铁厂园区开发平台案例,覆盖功能点包括图展示、图层管理控制、图层在线编辑(增删改查)、poi兴趣点管理、三维模型单体化以及交互点击高亮弹窗展示、地图点查查询、量算工具等等,适合学习cesium与前端框架结合开发3D可视化项目。

demo源码运行环境以及配置

1.jdk1.8环境配置,geoserver集成在tomcat运行需要
2.geoserver,发布地图服务
3.demo项目工程html+js+css
4.demo里面提供tomcat,里面集成geoserver以及三维模型数据,建议直接用

技术栈

cesium版本相对低
html5
js

示例效果
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
核心源码

var viewer;
var tilesets = [];
if (!viewer) viewer = initViewer();
window.viewer = viewer;
window.isClickQuery = true;
function initViewer() {var image_Source = new Cesium.UrlTemplateImageryProvider({//url: 'http://mt0.google.cn/vt/lyrs=t,r&hl=zh-CN&gl=cn&x={x}&y={y}&z={z}',url:"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",//url: "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}",credit: "",});viewer = new Cesium.Viewer("map", {// terrainProvider: new Cesium.CesiumTerrainProvider({//   url: "http://data.marsgis.cn/terrain",//   enablePickFeatures: false,// }),selectionIndicator: false,infoBox: false,sceneModePicker: false,baseLayerPicker: false,fullscreenButton: false,timeline: false,animation: false,geocoder: false, //地名查找,默认truehomeButton: false, //主页按钮,默认truenavigationHelpButton: false, //导航帮助说明,默认truenavigationInstructionsInitiallyVisible: false,//关闭地球光环skyAtmosphere: false,imageryProvider: image_Source,});var utc=Cesium.JulianDate.fromDate(new Date("2019/08/04 06:00:00"));//UTCviewer.clock.currentTime = Cesium.JulianDate.addHours(utc,8,new Cesium.JulianDate());//北京时间=UTC+8=GMT+8viewer._cesiumWidget._creditContainer.style.display = "none";//地图范围跳转var cartographicWS = [MapConfig.mapInitParams.extent.xmin,MapConfig.mapInitParams.extent.ymin,];var cartographicEN = [MapConfig.mapInitParams.extent.xmax,MapConfig.mapInitParams.extent.ymax,];var destination = Cesium.Rectangle.fromDegrees(cartographicWS[0],cartographicWS[1],cartographicEN[0],cartographicEN[1]);viewer.camera.setView({// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州destination: new Cesium.Cartesian3(-9572992.58727217, 26560459.994496826, 16289675.895258622),},{duration: 5,});// viewer.camera.flyTo({//   destination: destination,// },{//   duration: 5,//   offset: new Cesium.HeadingPitchRange(//     0.0,//     Cesium.Math.toRadians(-20.0),//     24056907//   )// });//创建地图导航控件viewer.extend(Cesium.viewerCesiumNavigationMixin, {defaultResetView: destination,});//显示地图当前坐标show3DCoordinates();// 禁用默认的实体双击动作。viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);//临时测试加载tif的tms瓦片服务/*var layers = viewer.scene.imageryLayers;layers.addImageryProvider(// new Cesium.UrlTemplateImageryProvider({//   url: MapConfig.tmsdomURL// })new Cesium.TileMapServiceImageryProvider({url: MapConfig.tmsdomURL,fileExtension: 'png'}));*///3dtiles单体化模型加载/*var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({url: MapConfig.Tiles3D.url,modelMatrix: Cesium.Matrix4.fromArray([0.1869180209750189,-0.8523144464483328,0.4884892402195312,0,0.2987505001302249,0.5230194918510269,0.7982472986586509,0,-0.9358470986794386,-0.0032704004901111805,0.352391135492809,0,-23040.115059180185,-69.02736813761294,-15930.330225577112,1,]),}));// var temp = {};// temp[MapConfig.Tiles3D.url] = tileset;tilesets.push(tileset);viewer.flyTo(tileset, {duration: 5,offset: new Cesium.HeadingPitchRange(0.0,Cesium.Math.toRadians(-20.0),700),});*/clickQuery.activate();return viewer;
}
/** 显示地图当前坐标*/
function show3DCoordinates() {//地图底部工具栏显示地图坐标信息var elementbottom = document.createElement("div");$(".cesium-viewer").append(elementbottom);elementbottom.style.width = "100%";elementbottom.style.height = "30px";elementbottom.style.background = "rgba(0,0,0,0.5)";elementbottom.style.position = "absolute";elementbottom.style.bottom = "0px";elementbottom.style.cursor = "default";var coordinatesDiv = document.getElementById("map_coordinates");if (coordinatesDiv) {coordinatesDiv.style.display = "block";} else {coordinatesDiv = document.createElement("div");coordinatesDiv.id = "map_coordinates";//coordinatesDiv.style.zIndex = "50";coordinatesDiv.style.bottom = "1px";coordinatesDiv.style.height = "29px";coordinatesDiv.style.position = "absolute";coordinatesDiv.style.overflow = "hidden";coordinatesDiv.style.textAlign = "center";coordinatesDiv.style.left = "70px";coordinatesDiv.style.lineHeight = "29px";coordinatesDiv.innerHTML ="<span id='cd_label' style='font-size:13px;text-align:center;font-family:微软雅黑;color:#edffff;'>暂无坐标信息</span>";$(".cesium-viewer").append(coordinatesDiv);var handler3D = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);handler3D.setInputAction(function (movement) {var pick = new Cesium.Cartesian2(movement.endPosition.x,movement.endPosition.y);if (pick) {var cartesian = viewer.scene.globe.pick(viewer.camera.getPickRay(pick),viewer.scene);if (cartesian) {//世界坐标转地理坐标(弧度)var cartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);if (cartographic) {//海拔var height = viewer.scene.globe.getHeight(cartographic);//视角海拔高度var he = Math.sqrt(viewer.scene.camera.positionWC.x *viewer.scene.camera.positionWC.x +viewer.scene.camera.positionWC.y *viewer.scene.camera.positionWC.y +viewer.scene.camera.positionWC.z *viewer.scene.camera.positionWC.z);var he2 = Math.sqrt(cartesian.x * cartesian.x +cartesian.y * cartesian.y +cartesian.z * cartesian.z);//地理坐标(弧度)转经纬度坐标var point = [(cartographic.longitude / Math.PI) * 180,(cartographic.latitude / Math.PI) * 180,];if (!height) {height = 0;}if (!he) {he = 0;}if (!he2) {he2 = 0;}if (!point) {point = [0, 0];}coordinatesDiv.innerHTML ="<span id='cd_label' style='font-size:13px;text-align:center;font-family:微软雅黑;color:#edffff;'>视角高度:" +(he - he2).toFixed(2) +"米&nbsp;&nbsp;&nbsp;&nbsp;海拔高度:" +height.toFixed(2) +"米&nbsp;&nbsp;&nbsp;&nbsp;经度:" +point[0].toFixed(6) +"&nbsp;&nbsp;纬度:" +point[1].toFixed(6) +"</span>";}}}}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);}
}
function initOverlay() {}
function hideOverlay() {overlay.close();
}
function changeModelStyle(pickedFeature, color) {if (!Cesium.defined(pickedFeature)) {var primitives = viewer.scene._primitives._primitives;if(primitives.length > 0){for (var i = 0; i < primitives.length; i++) {console.log("ddddddddddddddd")if(primitives[i] instanceof Cesium.Cesium3DTileset){primitives[i].style = new Cesium.Cesium3DTileStyle();}}}// for (var i = 0; i < tilesets.length; i++) {//   tilesets[i].style = new Cesium.Cesium3DTileStyle();// }return;}var selectbuilding = pickedFeature.getProperty('id');var selectcontent = "${id} === \'" + selectbuilding + "\'";var transparentStyle = new Cesium.Cesium3DTileStyle({color: {conditions: [[selectcontent, color],["true", "color('#FFFFFF')"]//true表示剩余的显示的对象]},});pickedFeature.tileset.style = transparentStyle;
}
function addModelStyle(selected, moved) {var transparentStyle = new Cesium.Cesium3DTileStyle({color: {conditions: [["${id} === \'" + selected.getProperty('id') + "\'", "color('#ff0000')"],["${id} === \'" + moved.getProperty('id') + "\'", "color('#ff0')"],["true", "color('#FFFFFF')"]//true表示剩余的显示的对象]},});selected.tileset.style = transparentStyle;
}
http://www.dtcms.com/a/393293.html

相关文章:

  • 电商开放平台API接口对比爬虫的优势有哪些?
  • SpringDoc-OpenApi 现代化 API 文档生成工具介绍+使用
  • 打造现象级H5答题游戏:《终极主题答题冒险》开源项目详解
  • 实验1.2呼吸灯实验指导书
  • 实验1.3通过for循环精确定时呼吸灯
  • 【c++】多态(一)
  • 01、Python从入门到癫狂:基础
  • uniapp 弹窗
  • 17.2 《16小时→2.3小时!多模态AI颠覆PPT制作:跨国企业实战验证》
  • MyBatis 从入门到实战:环境搭建与核心原理详解
  • 深入剖析陌讯AIGC检测算法:Transformer架构在AIGC识别中的技术创新
  • 【Ai智能客服上篇】
  • 《C++程序设计》笔记p3
  • 华为数字化转型战略框架:从“1套方法+4类场景+3个平台”的全景设计
  • Redis:主从复制与哨兵模式解析
  • 【中压选型篇】中压电源进线与变压器选型全指南:从拓扑设计到并联运行
  • 【精品资料鉴赏】数据治理咨询项目实施方案
  • 基于陌讯AIGC检测算法的局限性探讨:最大512Token输入下的长文本处理方案
  • 应用随机过程(三)
  • A/B测试:随机化与观察单位不一致,如何处理更科学
  • 树拍易购商业模式解析:创新与合规并行的数实融合样本
  • 使用递归求阶乘的和
  • HTML 结构与常用标签
  • AI 智能体开发工作流从哪些方面入手?
  • USBL与DVL数据融合的实时定位系统,MATLAB仿真
  • 端到端与世界模型(1):自动驾驶的基础模型从 VLM 到 VLA
  • Let’s Encrypt 免费SSL证书一键获取 - 网页版极简教程
  • IDEA指定配置文件启动
  • Python实现基于教学的优化器 (Teaching-Learning-Based Optimization, TLBO) (附完整代码)
  • 视频图像数据档案管理