function select(){ let build= document.getElementById("build_name").value; let room = parseInt(document.getElementById("room_num").value); selectFunction(build,room); } function selectFunction(build,room) { showCustomer( "./jsp/ZB.jsp?build_name="+build+"&room_num="+room, function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { let P=eval('(' + xmlhttp.responseText + ')'); position_x=parseFloat(P.x); position_y=parseFloat(P.y); position_z=parseFloat(P.z); locat(position_x,position_y,position_z); } }); } function locat(x,y,z){ if(entity){ viewer.entities.remove(entity); } var entity = new Cesium.Entity({ id : document.getElementById("build_name").value+"——"+parseInt(document.getElementById("room_num").value), position : Cesium.Cartesian3.fromDegrees(x, y), point : { pixelSize : 30, color : Cesium.Color.WHITE.withAlpha(0.9), outlineColor : Cesium.Color.WHITE.withAlpha(0.9), outlineWidth : 1 } }); viewer.entities.add(entity); viewer.flyTo(entity, { offset : { heading : Cesium.Math.toRadians(0.0), pitch : Cesium.Math.toRadians(-90), range : z+20 } }); }
1select()從頁面獲取位置點名稱
2selectFunction(build,room)通過ajax從數據庫獲取位置點坐標,在ZB.jsp中將(x,y,z)保存為json格式輸出。
3locat(x,y,z)將視野轉到位置點
4注意,定位坐標x,y為經緯度