| | |
| | | var widget = viewer.cesiumWidget; |
| | | // try { |
| | | |
| | | var promise = scene.open(window.MYURL_CONFIG.SCENE_CBD); |
| | | Cesium.when.all(promise, function (layer) { |
| | | scene.camera.setView({ |
| | | destination: new Cesium.Cartesian3.fromDegrees(116.44621857300415, 39.899281526734555, 216.7793905027196), |
| | | orientation: { |
| | | heading: 0.41348036210986194, |
| | | pitch: -0.13636490404291735, |
| | | roll: 6.283185307179563 |
| | | } |
| | | }); |
| | | for (var i = 0; i < layer.length; i++) { |
| | | layer[i].selectEnabled = false; |
| | | } |
| | | // var promise = scene.open(window.MYURL_CONFIG.SCENE_CBD); |
| | | // Cesium.when.all(promise, function (layer) { |
| | | // scene.camera.setView({ |
| | | // destination: new Cesium.Cartesian3.fromDegrees(116.44621857300415, 39.899281526734555, 216.7793905027196), |
| | | // orientation: { |
| | | // heading: 0.41348036210986194, |
| | | // pitch: -0.13636490404291735, |
| | | // roll: 6.283185307179563 |
| | | // } |
| | | // }); |
| | | // for (var i = 0; i < layer.length; i++) { |
| | | // layer[i].selectEnabled = false; |
| | | // } |
| | | |
| | | sightline.build(); |
| | | }, function (e) { |
| | | if (widget._showRenderLoopErrors) { |
| | | var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?'; |
| | | widget.showErrorPanel(title, undefined, e); |
| | | } |
| | | }); |
| | | sightline.build(); |
| | | // }, function (e) { |
| | | // if (widget._showRenderLoopErrors) { |
| | | // var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?'; |
| | | // widget.showErrorPanel(title, undefined, e); |
| | | // } |
| | | // }); |
| | | // } catch (e) { |
| | | // if (widget._showRenderLoopErrors) { |
| | | // var title = '渲染时发生错误,已停止渲染。'; |
| | |
| | | var tf = false;//当前点击状态是否是 添加目标点 |
| | | |
| | | var num = 0;//添加的目标点的点号 |
| | | var couldRemove = false;//是否能移除目标点 |
| | | var tooltip = window.MYcreateTooltip(viewer._element) |
| | | that.couldRemove = false;//是否能移除目标点 |
| | | that.tooltip = window.MYcreateTooltip(viewer._element) |
| | | var handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point); |
| | | handlerPoint.drawEvt.addEventListener(function (result) { |
| | | //添加观察点 |
| | |
| | | |
| | | |
| | | |
| | | var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); |
| | | that.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); |
| | | |
| | | document.getElementById("addViewPointthroughSee").onclick = function () { |
| | | if (tf == false) { |
| | |
| | | return; |
| | | } |
| | | viewer.entities.removeAll(); |
| | | if (couldRemove) { |
| | | if (that.couldRemove) { |
| | | sightline.removeAllTargetPoint(); |
| | | } |
| | | handlerPoint.activate(); |
| | | handler.setInputAction(function (evt) { |
| | | that.handler.setInputAction(function (evt) { |
| | | |
| | | //鼠标移动,更新最后一次添加的目标点的位置 |
| | | var position = scene.pickPosition(evt.endPosition); |
| | |
| | | $('body').removeClass('drawCur').addClass('drawCur'); |
| | | } |
| | | //鼠标移动事件,更新点 |
| | | handler.setInputAction(function (evt) { |
| | | tooltip.showAt(evt.endPosition, '<p>点击确定观察点</p>'); |
| | | that.handler.setInputAction(function (evt) { |
| | | that.tooltip.showAt(evt.endPosition, '<p>点击确定观察点</p>'); |
| | | }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | //鼠标点击事件,添加点 |
| | | handler.setInputAction(function (e) { |
| | | that.handler.setInputAction(function (e) { |
| | | $('body').removeClass('drawCur'); |
| | | mv = true; |
| | | tooltip.setVisible(false); |
| | | handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | that.tooltip.setVisible(false); |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | } else { |
| | | layer.tips('正在添加目标点,请先右键关闭', $('#addViewPointthroughSee'), { tips: [1, 'red'] }); |
| | |
| | | } |
| | | |
| | | //鼠标点击事件,添加点 |
| | | handler.setInputAction(function (e) { |
| | | that.handler.setInputAction(function (e) { |
| | | var position = scene.pickPosition(e.position); |
| | | addTarget(position); |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | |
| | | //鼠标移动事件,更新点 |
| | | handler.setInputAction(function (evt) { |
| | | that.handler.setInputAction(function (evt) { |
| | | |
| | | //鼠标移动,更新最后一次添加的目标点的位置 |
| | | var position = scene.pickPosition(evt.endPosition); |
| | |
| | | name: "point0" |
| | | }); |
| | | } |
| | | tooltip.showAt(evt.endPosition, '<p>点击确定目标点右键结束</p>'); |
| | | that.tooltip.showAt(evt.endPosition, '<p>点击确定目标点右键结束</p>'); |
| | | }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | |
| | | //鼠标右键事件,结束 |
| | | handler.setInputAction(function () { |
| | | that.handler.setInputAction(function () { |
| | | viewer.enableCursorStyle = true; |
| | | $('body').removeClass('drawCur'); |
| | | tooltip.setVisible(false); |
| | | handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | that.tooltip.setVisible(false); |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | tf = false; |
| | | }, Cesium.ScreenSpaceEventType.RIGHT_CLICK); |
| | | } else { |
| | |
| | | mv = false; |
| | | tf = false; |
| | | handlerPoint.clear(); |
| | | that.tooltip.setVisible(false); |
| | | viewer.entities.removeAll(); |
| | | if (couldRemove) { |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | if (that.couldRemove) { |
| | | sightline.removeAllTargetPoint(); |
| | | couldRemove = false; |
| | | that.couldRemove = false; |
| | | } |
| | | viewer.enableCursorStyle = true; |
| | | $('body').removeClass('drawCur'); |
| | | } else { |
| | | layer.tips('正在添加目标点,请先右键关闭', $('#addViewPointthroughSee'), { tips: [1, 'red'] }); |
| | | layer.tips('正在添加目标点,请先右键关闭', $('#clearthroughSee'), { tips: [1, 'red'] }); |
| | | |
| | | } |
| | | } |
| | |
| | | position: cartographic, |
| | | name: name |
| | | }); |
| | | couldRemove = true; |
| | | that.couldRemove = true; |
| | | } |
| | | } |
| | | |
| | |
| | | return [longitude, latitude, height]; |
| | | } |
| | | |
| | | that.promise = promise; |
| | | // that.promise = promise; |
| | | that.addViewFlag = addViewFlag; |
| | | that.addTargetFlag = addTargetFlag; |
| | | that.handlerPoint = handlerPoint; |
| | | that.sightline = sightline; |
| | | |
| | | }, |
| | | promise: '', |
| | | // promise: '', |
| | | addViewFlag: '', |
| | | addTargetFlag: '', |
| | | couldRemove: '', |
| | | sightline: '', |
| | | tooltip: '', |
| | | handler: '', |
| | | handlerPoint: '', |
| | | closesthroughSee: function (froms) { |
| | | console.log(`${this.name}--guanbi`); |
| | | that = this; |
| | | |
| | | Cesium.when.all(that.promise, function (layer) { |
| | | for (var i = 0; i < layer.length; i++) { |
| | | that.map.scene.layers.remove(layer[i].name) |
| | | } |
| | | }) |
| | | // Cesium.when.all(that.promise, function (layer) { |
| | | // for (var i = 0; i < layer.length; i++) { |
| | | // that.map.scene.layers.remove(layer[i].name) |
| | | // } |
| | | // }) |
| | | if (that.handler.removeInputAction) { |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | that.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
| | | } |
| | | if (that.tooltip.setVisible) { |
| | | that.tooltip.setVisible(false); |
| | | } |
| | | if (that.handlerPoint.clear) { |
| | | that.handlerPoint.clear(); |
| | | } |
| | | that.addViewFlag = false; |
| | | that.addTargetFlag = false; |
| | | that.handlerPoint.clear(); |
| | | |
| | | that.map.entities.removeAll(); |
| | | if (couldRemove) { |
| | | sightline.removeAllTargetPoint(); |
| | | couldRemove = false; |
| | | if (that.couldRemove) { |
| | | that.sightline.removeAllTargetPoint(); |
| | | that.couldRemove = false; |
| | | } |
| | | that.map.enableCursorStyle = true; |
| | | $('body').removeClass('drawCur'); |