Click on the highlighted event cesium surface
The main function: for example, you load the json, geojson or topojson data. After loading it, is divided into a number of faces, now click on a surface to be achieved, the surface change color; then click on another face, another face surface restoration highlighting before. (There do not know, please add the relevant study group: 854 184 700)
On the following codes:
1 function hightlightLine() {
2 var temp = new Array();
3 function linehHghtlight(nameId) {
4 var exists = temp.indexOf(nameId);
5 if (exists <= -1) {
6 temp.push(nameId);
7 } else {
8 temp.splice(exists, 1); //删除对应的nameID
9 }
10 }
11 viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
12 var pickedFeature = viewer.scene.pick(movement.position);
13
14 //判断之前是否有高亮面存在
15 if (highlightFace) {
16 highlightFace.material = highlightFace.material0;
17 }
18 pickedFeature.id.polygon.material0 = pickedFeature.id.polygon.material;
19 pickedFeature.id.polygon.material = Cesium.Color.WHITE;
20 highlightFace = pickedFeature.id.polygon;
21 showDivPositionOld =pickedFeature.id.properties;
22 is
23 is IF ( typeof ! (pickedFeature) = "undefined") // mouse is point to the surface
24 var ID = pickedFeature.id;
25 linehHghtlight (ID);
26 is }, Cesium.ScreenSpaceEventType.LEFT_CLICK );
27 }
There are doubts, please add the relevant study group: 854 184 700