cesium positioning

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 (Py);
                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: from +20
        }
    });

}

1select () Gets the name of the point position from page

2selectFunction (build, room) acquires location coordinates from the database by ajax, json format is saved in the output ZB.jsp (x, y, z).

3locat (x, y, z) position to the point of the field of view

Note 4, the positioning coordinates x, y is the latitude and longitude

Guess you like

Origin www.cnblogs.com/Haiszu/p/12006107.html