Cesium图元管理和事件处理
生活随笔
收集整理的這篇文章主要介紹了
Cesium图元管理和事件处理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用過cesium圖元api添加的幾何圖形都知道;起事件處理方式和數據綁定問題都和entity處理方式不一致。
entity方式添加的事件處理
var cartesian = viewer.scene.pickPosition(e.position);//地圖點位查詢let pick = viewer.scene.pick(e.position);if (Cesium.defined(pick) && pick.id && pick.id.type === "marker") {isCanCreate = true_self.pickValue = pick.id;let heading = viewer.camera.heading, pitch = viewer.camera.pitch, roll = viewer.camera.roll;console.log("==========", heading, pitch, roll);// if (pick.id.feature == '12') {// viewer.flyTo(_self.pickValue, {// offset: {// heading: 2.990358455542995, // 方向// pitch: -0.5403975721607086,// 傾斜角度// range: 11100// }// }, 5000);// } else {// viewer.flyTo(_self.pickValue, {// offset: {// heading: heading, // 方向// pitch: pitch,// 傾斜角度// range: 11100// }// }, 5000);// }viewer.flyTo(_self.pickValue, {offset: {heading: heading, // 方向pitch: pitch,// 傾斜角度range: 11100}}, 5000);其優點:可以擴充數據,但是性能不高。大批量點位則會卡頓
primitive圖元方式添加
if (Cesium.defined(pick) && pick.id && typeof pick.id === "string" && ~pick.id.indexOf("$camera")) {isCanCreate = truelet camera = _self.cacheCameras[pick.id.split("$camera")[0]];let lon = camera.lon || camera.longitude, lat = camera.lat || camera.latitude;let cartographic = Cesium.Cartographic.fromDegrees(lon, lat);let height = viewer.scene.globe.getHeight(cartographic);let pick1 = Cesium.Cartesian3.fromDegrees(lon, lat, 0)let heading = viewer.camera.heading, pitch = viewer.camera.pitch, roll = viewer.camera.roll;_self.pickValue = {_obj: camera,_lng: lon.toFixed(6),_lat: lat.toFixed(6),_h: Math.abs(height).toFixed(2) || "68.8",_position: {_value: pick1}};viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees(parseFloat(lon), parseFloat(lat), 11190),duration: 3, //定位的時間間隔}, 5000);if (_self.camera) {_self.$refs.cameraDetailRef && _self.$refs.cameraDetailRef.hide()_self.$refs.poiRef && _self.$refs.poiRef.hide()_self.pointShowBtns = true;return false}}其優點:可以處理海量數據,性能高。但是使用非常不方便,數據配置復雜。需要用id緩存的方式處理。
總結
以上是生活随笔為你收集整理的Cesium图元管理和事件处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: asp.net2.0学习指导 菜鸟到中级
- 下一篇: 结合stata和pyecharts对双1