首页 > 其他 > 详细

Cesium点击事件:获取wms服务矢量数据属性字段信息

时间:2019-10-08 23:46:34      阅读:1025      评论:0      收藏:0      [点我收藏+]
 1 viewer.screenSpaceEventHandler.setInputAction(function leftClick(movement) {
 2            var pickedFeature = viewer.scene.pick(movement.position);
 3              /*var slectEntity=viewer._selectedEntity;
 4             var selectionIndicatorViewModel = viewer._selectionIndicator.viewModel;
 5             if (typeof (pickedFeature) != "undefined")   //鼠标是否点到线上
 6             {
 7                 var name_id = pickedFeature.id.nameID;  //获取每条线的nameID
 8                 if(Cesium.defined(name_id)){
 9                 Hightlightline(name_id);
10                 }
11             }*/
12             var field_ZLDWDM;
13             var ray = viewer.camera.getPickRay(movement.position);
14             var cartesian = viewer.scene.globe.pick(ray, viewer.scene);
15             if (cartesian) {
16               var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
17               if (cartographic) {
18                  var xy = new Cesium.Cartesian2();
19                  var alti = viewer.camera.positionCartographic.height;
20                  var level = getLevel(alti);
21                  if (imageryProvider_WuJin1.ready) {
22                      xy = imageryProvider_WuJin1.tilingScheme.positionToTileXY(cartographic, level, xy);
23                      var promise = imageryProvider_WuJin1.pickFeatures(xy.x, xy.y, level, cartographic.longitude, cartographic.latitude);
24                     Cesium.when(promise, function (data) {
25                         if (data && data.length > 0) {
26                            field_ZLDWDM=data[0].properties.ZLDWDM;
27                         } 
28                      });
29                  } 
30               } 
31            } 
32            if(typeof (field_ZLDWDM) != "undefined")
33            {
34             window.open(‘http://www.baidu.com?region_code=10068&type=1‘);
35            }
36             //
37         }, Cesium.ScreenSpaceEventType.LEFT_UP);//LEFT_CLICK
38 
39         function getLevel(height) {
40            if (height > 48000000) {
41               return 0;
42            } else if (height > 24000000) {
43               return 1;
44            } else if (height > 12000000) {
45               return 2;
46            } else if (height > 6000000) {
47               return 3;
48            } else if (height > 3000000) {
49               return 4;
50            } else if (height > 1500000) {
51               return 5;
52            } else if (height > 750000) {
53               return 6;
54            } else if (height > 375000) {
55               return 7;
56            } else if (height > 187500) {
57               return 8;
58            } else if (height > 93750) {
59               return 9;
60            } else if (height > 46875) {
61               return 10;
62            } else if (height > 23437.5) {
63               return 11;
64            } else if (height > 11718.75) {
65               return 12;
66            } else if (height > 5859.38) {
67               return 13;
68            } else if (height > 2929.69) {
69               return 14;
70            } else if (height > 1464.84) {
71               return 15;
72            } else if (height > 732.42) {
73               return 16;
74            } else if (height > 366.21) {
75               return 17;
76            } else {
77               return 18;
78            }
79        }

 

Cesium点击事件:获取wms服务矢量数据属性字段信息

原文:https://www.cnblogs.com/pumpkin-123/p/11638161.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!