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)将视野转到位置点

12-26 14:56