|
@@ -0,0 +1,50 @@
|
|
|
+let handler_cockpit = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export const init_handler = () => {
|
|
|
+
|
|
|
+ if (handler_cockpit == null) {
|
|
|
+ handler_cockpit = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
|
+ }
|
|
|
+ handler_cockpit.setInputAction(async event => {
|
|
|
+ let pickObj = viewer.scene.pick(event.position);
|
|
|
+ var position = viewer.scene.pickPosition(event.position);
|
|
|
+
|
|
|
+ if (!position)//点击到地球之外
|
|
|
+ return false;
|
|
|
+ var cartographic = Cesium.Cartographic.fromCartesian(position);
|
|
|
+
|
|
|
+
|
|
|
+ let longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
|
|
+ let latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
|
|
+ let height = cartographic.height;
|
|
|
+ let heading = viewer.scene.camera.heading;
|
|
|
+ let pitch = viewer.scene.camera.pitch;
|
|
|
+ // that.addSceneFun()
|
|
|
+
|
|
|
+ if (!position) {
|
|
|
+ position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
|
|
|
+ }
|
|
|
+ if (Cesium.defined(pickObj)) {
|
|
|
+
|
|
|
+ if (pickObj.primitive instanceof Cesium.Primitive && pickObj.id.properties && pickObj.id.properties.type == '国有建设用地完成项目') {//点击primitive
|
|
|
+ //primitive相关操作
|
|
|
+ let propertyNames = pickObj.id.properties.propertyNames
|
|
|
+ propertyNames.forEach((res) => {
|
|
|
+ console.log(res,pickObj.id.properties[res]._value);
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ handler_cockpit.destroy();
|
|
|
+ handler_cockpit = null;
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
|
+
|
|
|
+
|
|
|
+}
|