123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <!-- 修改 木遥(微信: http://marsgis.cn/weixin.html ) -->
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
- <meta name="apple-touch-fullscreen" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="format-detection" content="telephone=no" />
- <meta name="x5-fullscreen" content="true" />
- <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
- <!-- 标题及搜索关键字 -->
- <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
- <meta
- name="description"
- content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
- />
- <link rel="shortcut icon" type="image/x-icon" href="" />
- <title>水域GeoJson图层 </title>
- <script
- type="text/javascript"
- src="../lib/include-lib.js"
- libpath="../lib/"
- include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"
- ></script>
- <link href="css/style.css" rel="stylesheet" />
- </head>
- <body class="dark">
- <!--加载前进行操作提示,优化用户体验-->
- <div id="mask" class="signmask" onclick="removeMask()"></div>
- <div id="mars3dContainer" class="mars3d-container"></div>
- <!-- 面板 -->
- <div class="infoview" style="width: 230px; text-align: center">
- <h4>闸门控制</h4>
- <div class="input-group">
- <span class="input-group-addon" id="basic-addon1">高度(米)</span>
- <input type="number" id="txt_zmmi" class="form-control" min="0" max="4" step="0.1" value="2" aria-describedby="basic-addon1" />
- </div>
- <div class="input-group">
- <span class="input-group-addon" id="basic-addon1">时长(秒)</span>
- <input type="number" id="txt_zmmiao" class="form-control" min="0" max="10" step="1" value="3" aria-describedby="basic-addon1" />
- </div>
- <div class="input-group text-right">
- <input id="btnOpenZm" type="button" class="btn btn-primary" value="开启" onclick="openZm()" />
- <input id="btnCloseZm" type="button" class="btn btn-primary" value="关闭" onclick="closeZm()" />
- </div>
- </div>
- <script src="./js/common.js"></script>
- <script type="text/javascript">
- "use script"; //开发环境建议开启严格模式
- var map;
- var graphic;
- var waterLayer;
- function initMap(options) {
- //合并属性参数,可覆盖config.json中的对应配置
- var mapOptions = mars3d.Util.merge(options, {
- scene: {
- center: { lat: 29.791718, lng: 121.479859, alt: 29, heading: 187, pitch: -14 },
- },
- layers: [
- {
- type: "3dtiles",
- name: "整体模型",
- url: "//data.mars3d.cn/3dtiles/max-fsdzm/tileset.json",
- position: { alt: 15.2 },
- maximumScreenSpaceError: 1,
- maximumMemoryUsage: 1024,
- show: true,
- },
- {
- type: "geojson",
- name: "河流(面状)",
- url: "//data.mars3d.cn/file/geojson/hedao-nei.json",
- symbol: {
- type: "waterCombine",
- styleOptions: {
- height: 17, //水面高度
- normalMap: "img/textures/waterNormals.jpg", // 水正常扰动的法线图
- frequency: 8000.0, // 控制波数的数字。
- animationSpeed: 0.02, // 控制水的动画速度的数字。
- amplitude: 5.0, // 控制水波振幅的数字。
- specularIntensity: 0.8, // 控制镜面反射强度的数字。
- baseWaterColor: "#006ab4", // rgba颜色对象基础颜色的水。#00ffff,#00baff,#006ab4
- blendColor: "#006ab4", // 从水中混合到非水域时使用的rgba颜色对象。
- opacity: 0.4, //透明度
- clampToGround: false, //是否贴地
- },
- },
- show: true,
- },
- ],
- });
- //创建三维地球场景
- map = new mars3d.Map("mars3dContainer", mapOptions);
- waterLayer = new mars3d.layer.GeoJsonLayer({
- name: "河流(面状)",
- url: "//data.mars3d.cn/file/geojson/hedao-wai.json",
- symbol: {
- type: "waterCombine",
- styleOptions: {
- height: 16, //水面高度
- normalMap: "img/textures/waterNormals.jpg", // 水正常扰动的法线图
- frequency: 8000.0, // 控制波数的数字。
- animationSpeed: 0.02, // 控制水的动画速度的数字。
- amplitude: 5.0, // 控制水波振幅的数字。
- specularIntensity: 0.8, // 控制镜面反射强度的数字。
- baseWaterColor: "#006ab4", // rgba颜色对象基础颜色的水。#00ffff,#00baff,#006ab4
- blendColor: "#006ab4", // 从水中混合到非水域时使用的rgba颜色对象。
- opacity: 0.4, //透明度
- clampToGround: false, //是否贴地
- },
- },
- });
- map.addLayer(waterLayer);
- //绑定事件
- waterLayer.on(mars3d.EventType.load, function (event) {
- console.log("数据加载完成", event);
- });
- waterLayer.on(mars3d.EventType.click, function (event) {
- console.log("单击了", event);
- });
- //闸门的控制
- graphic = new mars3d.graphic.ModelEntity({
- name: "闸门",
- position: [121.479813, 29.791278, 16],
- style: {
- url: "//data.mars3d.cn/gltf/mars/zhamen.glb",
- heading: 105,
- },
- });
- map.graphicLayer.addGraphic(graphic);
- }
- var minHeight = 16;
- var timeInv;
- //高度更新
- function updateHeight(height) {
- graphic.height = height; //阀门高度
- waterLayer.eachGraphic((graphic) => {
- graphic.updateHeight(height); //水域高度变化
- });
- }
- //参数保护
- function submitHeight() {
- let mi = Number($("#txt_zmmi").val());
- if (mi > 4) {
- haoutil.msg("高度值太大,请设置高度范围在0到4米之间");
- return true;
- }
- if (mi <= 0) {
- haoutil.msg("请设置高度范围在0到4米之间");
- return true;
- }
- let time = Number($("#txt_zmmiao").val());
- if (time > 10 || time <= 0) {
- haoutil.msg("建议时长范围在 0~10 秒之间");
- return true;
- }
- return false;
- }
- //开启阀门
- function openZm() {
- if (submitHeight()) {
- return;
- }
- var time = Number($("#txt_zmmiao").val());
- var mi = Number($("#txt_zmmi").val());
- var thisHeight = minHeight; //当前高度
- var endHeight = mi + minHeight; //结束高度
- var step = time / 0.1; //步长
- var stepHeight = (endHeight - thisHeight) / step; //每次阀门、水面上移高度
- //再次点击"开启"时从当前位置开启
- updateHeight(thisHeight);
- clearInterval(timeInv);
- timeInv = setInterval(() => {
- thisHeight += stepHeight; //上移后的当前高度,相当于时实更新
- if (thisHeight >= endHeight) {
- thisHeight = endHeight;
- clearInterval(timeInv); //清除定时器,当前阀门的高度值等于结束时阀门的高度值时,停止上移,关闭定时器
- }
- updateHeight(thisHeight);
- }, 100);
- }
- //关闭阀门
- function closeZm() {
- if (submitHeight()) {
- return; //return 之后就会直接结束这个函数,不会在往下走
- }
- var time = Number($("#txt_zmmiao").val());
- var mi = Number($("#txt_zmmi").val());
- var thisHeight = mi + minHeight;
- var endHeight = minHeight;
- var step = time / 0.1;
- var stepHeight = (endHeight - thisHeight) / step;
- updateHeight(thisHeight);
- clearInterval(timeInv);
- timeInv = setInterval(() => {
- thisHeight += stepHeight;
- if (thisHeight <= endHeight) {
- thisHeight = endHeight;
- clearInterval(timeInv);
- }
- updateHeight(thisHeight);
- }, 100);
- }
- </script>
- </body>
- </html>
|