From 89da62649161571834d3f8df7ce36f9967e6ba04 Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期二, 07 九月 2021 14:04:31 +0800
Subject: [PATCH] change cesium version
---
js/index.js | 517 +++++++++++++++++++--------------------------------------
1 files changed, 174 insertions(+), 343 deletions(-)
diff --git a/js/index.js b/js/index.js
index ee36b39..0884f26 100644
--- a/js/index.js
+++ b/js/index.js
@@ -1,404 +1,235 @@
-'use script' //寮�鍙戠幆澧冨缓璁紑鍚弗鏍兼ā寮�
+"use script"; //寮�鍙戠幆澧冨缓璁紑鍚弗鏍兼ā寮�
//绯荤粺涓诲叆鍙�
-var map //鍦扮悆瀵硅薄
-var request //浼犲叆鐨刧et鍙傛暟
-var useid = "admin" ;
-
-var currentDataType = 'hour';
-var currentDataTime = getDefaultDataTime();
-
-
-
-function getDefaultDataTime(){
-
- var now = new Date();
- //TODO
-
- return "2021-08-23 13:00:00";
-
-}
-
+var map; //鍦扮悆瀵硅薄
+var request; //浼犲叆鐨刧et鍙傛暟
//鍦板浘
-$(document).ready(function() {
- //鍒ゆ柇webgl鏀寔
- if (!mars3d.Util.webglreport()) {
- mars3d.Util.webglerror()
- }
+$(document).ready(function () {
+ //鍒ゆ柇webgl鏀寔
+ if (!mars3d.Util.webglreport()) {
+ mars3d.Util.webglerror();
+ }
- //璁板綍url浼犲叆鍙傛暟
- request = haoutil.system.getRequest()
- if (window.top) {
- //鏈夌埗绾�
- request = $.extend(request, haoutil.system.getRequest(window.top))
- }
+ //璁板綍url浼犲叆鍙傛暟
+ request = haoutil.system.getRequest();
+ if (window.top) {
+ //鏈夌埗绾�
+ request = $.extend(request, haoutil.system.getRequest(window.top));
+ }
- if (request.userid !=null){
- useid = request.userid;
- console.log(useid);
+ var configfile = "config/config.json"; //榛樿鍦板潃
+ if (request.config) {
+ //url浼犲叆鍦板潃
+ configfile = request.config;
+ }
- }
+ haoutil.loading.show();
- var configfile = 'config/config.json' //榛樿鍦板潃
- if (request.config) {
- //url浼犲叆鍦板潃
- configfile = request.config
- }
+ $.ajax({
+ type: "get",
+ dataType: "json",
+ url: configfile,
+ timeout: 0,
+ success: function (data) {
+ haoutil.loading.hide();
- haoutil.loading.show()
+ //鏋勫缓鍦板浘
+ initMap(data.map3d);
- $.ajax({
- type: 'get',
- dataType: 'json',
- url: configfile,
- timeout: 0,
- success: function(data) {
- haoutil.loading.hide()
+ setTimeout(removeMask, 3000); //娆㈣繋UI鍏抽棴澶勭悊
+ },
+ error: function (request, textStatus) {
+ removeMask();
+ haoutil.loading.hide();
+ haoutil.alert("1.璇锋鏌ユ枃浠跺唴 json 璇硶鏄惁瀛樺湪闂銆�<br />2.璇峰湪娴忚鍣ㄨ緭鍏ユ枃浠秛rl娴嬭瘯鏄惁鍙互璁块棶銆�", configfile + " 鏂囦欢鍔犺浇澶辫触");
+ console.log(textStatus, request);
+ },
+ });
- //鏋勫缓鍦板浘
- initMap(data.map3d)
-
- setTimeout(removeMask, 3000) //娆㈣繋UI鍏抽棴澶勭悊
- },
- error: function(request, textStatus) {
- removeMask()
- haoutil.loading.hide()
- haoutil.alert('1.璇锋鏌ユ枃浠跺唴 json 璇硶鏄惁瀛樺湪闂銆�<br />2.璇峰湪娴忚鍣ㄨ緭鍏ユ枃浠秛rl娴嬭瘯鏄惁鍙互璁块棶銆�', configfile + ' 鏂囦欢鍔犺浇澶辫触')
- console.log(textStatus, request)
- },
- })
-
- initUI()
-})
+ initUI();
+});
function removeMask() {
- $('#mask').remove()
+ $("#mask").remove();
}
//UI鐣岄潰鐩稿叧
function initUI() {
- haoutil.oneMsg('棣栨璁块棶绯荤粺鏃犵紦瀛樹細鐣ユ參锛岃鑰愬績绛夊緟锛�', 'load3d_tip')
+ haoutil.oneMsg("棣栨璁块棶绯荤粺鏃犵紦瀛樹細鐣ユ參锛岃鑰愬績绛夊緟锛�", "load3d_tip");
}
//鍒濆鍖栧湴鍥�
function initMap(mapOptions) {
- //鍚堝苟灞炴�у弬鏁帮紝鍙鐩朿onfig.json涓殑瀵瑰簲閰嶇疆
- // mapOptions = mars3d.Util.merge(mapOptions, {})
+ //鍚堝苟灞炴�у弬鏁帮紝鍙鐩朿onfig.json涓殑瀵瑰簲閰嶇疆
+ // mapOptions = mars3d.Util.merge(mapOptions, {})
- //鍒涘缓涓夌淮鍦扮悆鍦烘櫙
- console.log(mapOptions);
+ //鍒涘缓涓夌淮鍦扮悆鍦烘櫙
+ map = new mars3d.Map("mars3dContainer", mapOptions);
- // array[] ;
-
- map = new mars3d.Map('mars3dContainer', mapOptions)
- //鏋勯�爓idget
- initWidget(map)
+ addFunctionalLayers();
- //濡傛灉鏈墄yz浼犲弬锛岃繘琛屽畾浣�
- if (haoutil.isutil.isNotNull(request.x) && haoutil.isutil.isNotNull(request.y)) {
- map.setCameraView(request, { duration: 0, isWgs84: true })
+ //鏋勯�爓idget
+ initWidget(map);
+
+ //濡傛灉鏈墄yz浼犲弬锛岃繘琛屽畾浣�
+ if (haoutil.isutil.isNotNull(request.x) && haoutil.isutil.isNotNull(request.y)) {
+ map.setCameraView(request, { duration: 0, isWgs84: true });
+ }
+
+ //寮�鍦哄姩鐢�
+ //map.openFlyAnimation();
+
+ //閽堝涓嶅悓缁堢鐨勪紭鍖栭厤缃�
+ if (haoutil.system.isPCBroswer()) {
+ // Cesium 1.61浠ュ悗浼氶粯璁ゅ叧闂弽璧版牱锛屽浜庢闈㈢鑰岃█杩樻槸寮�鍚緱濂斤紝
+ map.scene.postProcessStages.fxaa.enabled = true;
+
+ //榧犳爣婊氳疆鏀惧ぇ鐨勬闀垮弬鏁�
+ map.scene.screenSpaceCameraController._zoomFactor = 2.0;
+
+ //IE娴忚鍣ㄤ紭鍖�
+ if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 0) {
+ map.viewer.targetFrameRate = 20; //闄愬埗甯х巼
+ map.viewer.requestRenderMode = true; //鍙栨秷瀹炴椂娓叉煋
}
+ } else {
+ //榧犳爣婊氳疆鏀惧ぇ鐨勬闀垮弬鏁�
+ map.scene.screenSpaceCameraController._zoomFactor = 5.0;
- //寮�鍦哄姩鐢�
- map.openFlyAnimation()
+ //绉诲姩璁惧涓婄鎺変互涓嬪嚑涓�夐」锛屽彲浠ョ浉瀵规洿鍔犳祦鐣�
+ map.viewer.requestRenderMode = true; //鍙栨秷瀹炴椂娓叉煋
+ map.scene.fog.enabled = false;
+ map.scene.skyAtmosphere.show = false;
+ map.scene.globe.showGroundAtmosphere = false;
+ }
- //閽堝涓嶅悓缁堢鐨勪紭鍖栭厤缃�
- if (haoutil.system.isPCBroswer()) {
- // Cesium 1.61浠ュ悗浼氶粯璁ゅ叧闂弽璧版牱锛屽浜庢闈㈢鑰岃█杩樻槸寮�鍚緱濂斤紝
- map.scene.postProcessStages.fxaa.enabled = true
+ //浜屼笁缁村垏鎹笉鐢ㄥ姩鐢�
+ if (map.sceneModePicker) {
+ map.sceneModePicker.viewModel.duration = 0.0;
+ }
- //榧犳爣婊氳疆鏀惧ぇ鐨勬闀垮弬鏁�
- map.scene.screenSpaceCameraController._zoomFactor = 2.0
+ //webgl娓叉煋澶辫触鍚庯紝鍒锋柊椤甸潰
+ // map.on(mars3d.EventType.renderError, function (scene, error) {
+ // window.location.reload();
+ // });
- //IE娴忚鍣ㄤ紭鍖�
- if (window.navigator.userAgent.toLowerCase().indexOf('msie') >= 0) {
- map.viewer.targetFrameRate = 20 //闄愬埗甯х巼
- map.viewer.requestRenderMode = true //鍙栨秷瀹炴椂娓叉煋
- }
- } else {
- //榧犳爣婊氳疆鏀惧ぇ鐨勬闀垮弬鏁�
- map.scene.screenSpaceCameraController._zoomFactor = 5.0
+ //缁戝畾鍗曞嚮鏄剧ずBIM鐨勬瀯浠舵爲
+ bindShowTilesParts();
- //绉诲姩璁惧涓婄鎺変互涓嬪嚑涓�夐」锛屽彲浠ョ浉瀵规洿鍔犳祦鐣�
- map.viewer.requestRenderMode = true //鍙栨秷瀹炴椂娓叉煋
- map.scene.fog.enabled = false
- map.scene.skyAtmosphere.show = false
- map.scene.globe.showGroundAtmosphere = false
- }
-
- //浜屼笁缁村垏鎹笉鐢ㄥ姩鐢�
- if (map.sceneModePicker) {
- map.sceneModePicker.viewModel.duration = 0.0
- }
-
- //webgl娓叉煋澶辫触鍚庯紝鍒锋柊椤甸潰
- map.scene.renderError.addEventListener(function (scene, error) {
- window.location.reload();
- });
-
- //缁戝畾鍗曞嚮鏄剧ずBIM鐨勬瀯浠舵爲
- bindShowTilesParts()
-
- //涓嬮潰鍙互缁х画鍔犻」鐩浉鍏崇殑鍏朵粬浠g爜
- // 鐩戞祴鐐规寚鏍� 鍒嗗尯闂�
-
-
-
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.tsp聽 < 聽0.02)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance1ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.tsp聽 > 聽0.02聽 && 聽attr.tsp聽 < 聽0.06)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance2ji.png"聽 };聽聽聽聽 }聽
- else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance3ji.png"聽 };聽聽聽聽 }
- }
-
- var聽 Layer聽 = 聽map.getLayer("鐩戞祴鐐规瘡鏃舵暟鎹�-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.tsp聽 < 聽0.02)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance1ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.tsp聽 > 聽0.02聽 && 聽attr.tsp聽 < 聽0.06)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance2ji.png"聽 };聽聽聽聽 }聽
- else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance3ji.png"聽 };聽聽聽聽 }
- }
-
- var聽 Layer聽 = 聽map.getLayer("鐩戞祴鐐规瘡澶╂暟鎹�-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.tsp聽 < 聽0.02)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance1ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.tsp聽 > 聽0.02聽 && 聽attr.tsp聽 < 聽0.06)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance2ji.png"聽 };聽聽聽聽 }聽
- else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/jiance3ji.png"聽 };聽聽聽聽 }
- }
-
- //寰珯鎸囨爣 鍒嗗尯闂�
- var聽 Layer聽 = 聽map.getLayer("寰珯姣忓垎鏁版嵁-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.pm25聽 < 聽5)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan1j.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽5聽 && 聽attr.pm25聽 < 聽7)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan2j.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽7聽 && 聽attr.pm25聽 < 聽9)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan3ji.png"聽 };聽聽聽聽 } else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan4ji.png"聽 };聽聽聽聽 }
- }
-
- var聽 Layer聽 = 聽map.getLayer("寰珯姣忔椂鏁版嵁-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.pm25聽 < 聽5)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan1j.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽5聽 && 聽attr.pm25聽 < 聽7)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan2j.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽7聽 && 聽attr.pm25聽 < 聽9)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan3ji.png"聽 };聽聽聽聽 } else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan4ji.png"聽 };聽聽聽聽 }
- }
-
-
-
- var聽 Layer聽 = 聽map.getLayer("寰珯姣忓ぉ鏁版嵁-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.pm25聽 < 聽5)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan1j.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽5聽 && 聽attr.pm25聽 < 聽7)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan2j.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽7聽 && 聽attr.pm25聽 < 聽9)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan3ji.png"聽 };聽聽聽聽 } else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/weizhan4ji.png"聽 };聽聽聽聽 }
- }
-
- //鍥芥帶鐐规寚鏍� 鍒嗗尯闂�
-
- var聽 Layer聽 = 聽map.getLayer("鍥芥帶鐐规瘡鍒嗘暟鎹�-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.pm25聽 < 聽15)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong1ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽15聽 && 聽attr.pm25聽 < 聽35)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong2ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽50聽 && 聽attr.pm25聽 < 聽75)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong3ji.png"聽 };聽聽聽聽 } else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong4ji.png"聽 };聽聽聽聽 }
- }
-
-
- var聽 Layer聽 = 聽map.getLayer("鍥芥帶鐐规瘡鏃舵暟鎹�-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.pm25聽 < 聽15)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong1ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽15聽 && 聽attr.pm25聽 < 聽35)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong2ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽50聽 && 聽attr.pm25聽 < 聽75)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong3ji.png"聽 };聽聽聽聽 } else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong4ji.png"聽 };聽聽聽聽 }
- }
-
- var聽 Layer聽 = 聽map.getLayer("鍥芥帶鐐规瘡澶╂暟鎹�-WFS");
- var聽 symbol聽 = 聽Layer.options.symbol;
- symbol.callback聽 = 聽 function(attr, 聽styleOpt)聽 {聽聽聽聽
- if聽 (attr.pm25聽 < 聽15)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong1ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽15聽 && 聽attr.pm25聽 < 聽35)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong2ji.png"聽 };聽聽聽聽 }聽
- else聽 if聽 (attr.pm25聽 > 聽50聽 && 聽attr.pm25聽 < 聽75)聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong3ji.png"聽 };聽聽聽聽 } else聽 {聽聽聽聽聽聽聽聽 return聽 {聽 image: 聽 "img/marker/guokong4ji.png"聽 };聽聽聽聽 }
- }
-
-
- //////////////////////////////////////////////////////////////////
-
- //鍒涘缓鐭㈤噺鏁版嵁鍥惧眰
- var graphicLayer = new mars3d.layer.GraphicLayer({ name: "鍑虹杞�" })
- map.addLayer(graphicLayer)
-
-
- //鍥惧眰绠$悊鐨勭浉鍏冲鐞嗭紝浠g爜鍦╘js\graphicManager.js
- //initLayerManager(graphicLayer)
-
- //鍔犱竴浜涙紨绀烘暟鎹�
- for (let i = 0; i < 20; i++) {
- let graphic = new mars3d.graphic.ModelEntity({
- style: {
- url: 'http://data.marsgis.cn/gltf/mars/qiche.gltf',
- scale: 0.6,
- minimumPixelSize: 30,
-
- },
- })
- graphicLayer.addGraphic(graphic)
- }
-
-
-
- //璁剧疆鍔ㄦ�佷綅缃�
- graphicLayer.eachGraphic((graphic) => {
- graphic.addDynamicPosition(randomPoint())
- })
- graphicLayer.eachGraphic((graphic) => {
- graphic.addDynamicPosition(randomPoint(), 500)
- })
-
- //瀹氭椂鏇存柊鍔ㄦ�佷綅缃紙setInterval涓烘紨绀猴級
- setInterval(() => {
- graphicLayer.eachGraphic((graphic) => {
- graphic.addDynamicPosition(randomPoint(), 500)
- })
- }, 10000)
+ //涓嬮潰鍙互缁х画鍔犻」鐩浉鍏崇殑鍏朵粬浠g爜
}
-
-//鍙栧尯鍩熷唴鐨勯殢鏈哄浘鏍�
-function randomPoint() {
- var jd = haoutil.math.random(121.068909 * 1000, 121.666411 * 1000) / 1000
- var wd = haoutil.math.random(30.977126 * 1000, 31.368503 * 1000) / 1000
- return Cesium.Cartesian3.fromDegrees(jd, wd, 30)
-}
-
//鍒濆鍖杦idget鐩稿叧
function initWidget(map) {
- haoutil.loading.show()
+ haoutil.loading.show();
- $.ajax({
- type: 'get',
- dataType: 'json',
- url: 'config/widget.json',
- timeout: 0,
- success: function(widgetCfg) {
- haoutil.loading.hide()
+ $.ajax({
+ type: "get",
+ dataType: "json",
+ url: "config/widget.json",
+ timeout: 0,
+ success: function (widgetCfg) {
+ haoutil.loading.hide();
- //url濡傛灉鏈変紶鍙傛椂鐨勫鐞�
- if (haoutil.isutil.isNotNull(request.widget)) {
- if (request.onlyStart) {
- widgetCfg.openAtStart = []
- }
- widgetCfg.openAtStart.push({
- uri: request.widget,
- name: request.name || '',
- windowOptions: {
- closeBtn: !request.onlyStart,
- },
- request: request,
- })
- map.flyHome({ duration: 0 })
- }
+ //url濡傛灉鏈変紶鍙傛椂鐨勫鐞�
+ if (haoutil.isutil.isNotNull(request.widget)) {
+ if (request.onlyStart) {
+ widgetCfg.openAtStart = [];
+ }
+ widgetCfg.openAtStart.push({
+ uri: request.widget,
+ name: request.name || "",
+ windowOptions: {
+ closeBtn: !request.onlyStart,
+ },
+ request: request,
+ });
+ map.flyHome({ duration: 0 });
+ }
- //鍒濆鍖杦idget绠$悊鍣�
- mars3d.widget.init(map, widgetCfg, './') //tip: 绗�3涓弬鏁版敮鎸佸畾涔墂idget鐩綍鐨勭浉瀵硅矾寰勩��
+ //鍒濆鍖杦idget绠$悊鍣�
+ mars3d.widget.init(map, widgetCfg, "./"); //tip: 绗�3涓弬鏁版敮鎸佸畾涔墂idget鐩綍鐨勭浉瀵硅矾寰勩��
- if (window.lastWidgetItem) {
- activateWidget(lastWidgetItem)
- lastWidgetItem = null
- }
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- haoutil.loading.hide()
- haoutil.alert('config/widget.json鏂囦欢鍔犺浇澶辫触锛�')
- },
- })
+ if (window.lastWidgetItem) {
+ activateWidget(lastWidgetItem);
+ lastWidgetItem = null;
+ }
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ haoutil.loading.hide();
+ haoutil.alert("config/widget.json鏂囦欢鍔犺浇澶辫触锛�");
+ },
+ });
- //widget鐩稿叧浜嬩欢鐩戝惉
- // mars3d.widget.on(mars3d.widget.EventType.load, function (event) {
- // console.log("寮曞叆鍔犺浇浜唚idget鐨刯s", event);
- // })
- // mars3d.widget.on(mars3d.widget.EventType.created, function (event) {
- // console.log("鍒涘缓浜唚idet", event);
- // })
- mars3d.widget.on(mars3d.widget.EventType.activated, function(event) {
- console.log('婵�娲讳簡widget', event)
- })
- mars3d.widget.on(mars3d.widget.EventType.disabled, function(event) {
- console.log('閲婃斁浜唚idget', event)
- })
+ //widget鐩稿叧浜嬩欢鐩戝惉
+ // mars3d.widget.on(mars3d.widget.EventType.load, function (event) {
+ // console.log("寮曞叆鍔犺浇浜唚idget鐨刯s", event);
+ // })
+ // mars3d.widget.on(mars3d.widget.EventType.created, function (event) {
+ // console.log("鍒涘缓浜唚idet", event);
+ // })
+ mars3d.widget.on(mars3d.widget.EventType.activated, function (event) {
+ console.log("婵�娲讳簡widget", event);
+ });
+ mars3d.widget.on(mars3d.widget.EventType.disabled, function (event) {
+ console.log("閲婃斁浜唚idget", event);
+ });
}
//bim鏋勪欢鐨勫鐞�
function bindShowTilesParts() {
- //鍗曞嚮鍦板浘浜嬩欢
- map.on(mars3d.EventType.clickGraphic, function(event) {
- if (!(event.pickedObject instanceof Cesium.Cesium3DTileFeature)) {
- //涓嶆槸BIM鏁版嵁鏃惰烦鍑�
- return
- }
+ //鍗曞嚮鍦板浘浜嬩欢
+ map.on(mars3d.EventType.clickGraphic, function (event) {
+ if (!(event.pickedObject instanceof Cesium.Cesium3DTileFeature)) {
+ //涓嶆槸BIM鏁版嵁鏃惰烦鍑�
+ return;
+ }
- let layer = event.layer
- if (!layer.options.scenetree) {
- //鏈厤缃畇cenetree鏃惰烦鍑�
- return
- }
+ let layer = event.layer;
+ if (!layer.options.scenetree) {
+ //鏈厤缃畇cenetree鏃惰烦鍑�
+ return;
+ }
- var tilesParts = 'widgets/tilesParts/widget.js'
+ var tilesParts = "widgets/tilesParts/widget.js";
- if (mars3d.widget.isActivate(tilesParts)) {
- var parts = mars3d.widget.getClass(tilesParts)
- if (parts.config.layerCfg == layer.options) {
- //褰撳墠宸叉縺娲�,骞朵笖鍗曞嚮浜嗙浉鍚屾ā鍨嬫椂璺冲嚭
- return
- }
- }
+ if (mars3d.widget.isActivate(tilesParts)) {
+ var parts = mars3d.widget.getClass(tilesParts);
+ if (parts.config.layerCfg == layer.options) {
+ //褰撳墠宸叉縺娲�,骞朵笖鍗曞嚮浜嗙浉鍚屾ā鍨嬫椂璺冲嚭
+ return;
+ }
+ }
- mars3d.widget.activate({
- name: layer.name + ' 鏋勪欢',
- uri: tilesParts,
- layerCfg: layer.options,
- disableOther: false,
- })
- })
+ mars3d.widget.activate({
+ name: layer.name + " 鏋勪欢",
+ uri: tilesParts,
+ layerCfg: layer.options,
+ disableOther: false,
+ });
+ });
}
//澶栭儴椤甸潰璋冪敤
-var lastWidgetItem
-
+var lastWidgetItem;
function activateWidget(item) {
- if (!map) {
- lastWidgetItem = item
- return
- }
- mars3d.widget.activate(item)
+ if (!map) {
+ lastWidgetItem = item;
+ return;
+ }
+ mars3d.widget.activate(item);
}
-
function disableWidget(item) {
- mars3d.widget.disable(item)
+ mars3d.widget.disable(item);
}
-
function activateFunByMenu(fun) {
- eval(fun)
+ eval(fun);
}
function goHome() {
- mars3d.widget.disableAll()
- map.flyHome()
+ mars3d.widget.disableAll();
+ map.flyHome();
}
-
-function activateWidget(uri) {
-
- // console.log('鍗曞嚮浜嗗伐鍏锋爮锛�' + uri);
-
- if (mars3d.widget.isActivate(uri)) {
- mars3d.widget.disable(uri)
- } else {
- var opt = {
- uri: uri,
- }
- mars3d.widget.activate(opt)
- }
-}
\ No newline at end of file
--
Gitblit v1.9.1