ansel0926
2022-05-16 cee67c9f4623f287ce96901763963d50cdc24736
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//搜索查询
function poisearch() {
 
    var queryStr = $("#txt_querypoi").val();
    if (queryStr != null && queryStr != "") {
        //根据项目的名字搜索
        $.ajax({
            type: "get",
            async: false,
            url: httpConfig.webApiUrl + "landstamp/front/3dtileList?name=" + queryStr,
            contentType: "application/json;charset=utf-8",
            timeout: 3000,
            success: function (data) {
                if (data == null || data.length == 0) {
                    layer.msg('未查询到数据!');
                    return;
                }
                var lng;
                var lat;
                var head = 0, pitch = -30, range = 1000, offsetLat = 0;
                for (var i = 0; i < data.length; i++) {
                    if (data[i].status == "0") {//禁用的模型 
                        continue;
                    }
                    var id = data[i].tilesId;
                    var projectId = data[i].projectId;
                    currentProjectId = projectId;
                    var url = httpConfig.nginxUrl + data[i].tilesUrl;
                    lng = data[i].lng;
                    lat = data[i].lat;
                    var x = data[i].tilesX == null ? 0 : data[i].tilesX;
                    var y = data[i].tilesY == null ? 0 : data[i].tilesY;
                    var z = data[i].tilesZ == null ? 0 : data[i].tilesZ;
                    var tilesType = data[i].tilesType;
 
                    if (tilesType == "building") {
                        head = data[i].camHeading == null ? 0 : data[i].camHeading;
                        pitch = data[i].camPitch == null ? -30 : data[i].camPitch;
                        range = data[i].camPoi == null ? 1000 : data[i].camPoi;
                        offsetLat = data[i].offsetLat == null ? 0 : data[i].offsetLat;
                    }        
                    var options = {
                        "id": id,
                        "url": url,
                        "lng": lng,
                        "lat": lat,
                        "x": x,
                        "y": y,
                        "z": z,
                        "tilesType": tilesType
                    };
                    // console.log(projectId);
                    add3dtiles(options);
                }
                
                let flyPromise = viewer.camera.flyTo({
                    duration: 3,
                    destination: Cesium.Cartesian3.fromDegrees(Number(lng), Number(lat) + Number(offsetLat), range),
                    orientation: {
                        heading: Cesium.Math.toRadians(head),                          //绕垂直于地心的轴旋转
                        pitch: Cesium.Math.toRadians(pitch),      //绕纬度线旋转
                        roll: Cesium.Math.toRadians(0)                                 //绕经度线旋转
                    },
 
                });
 
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log("ajax请求失败!");
            },
        });
 
    } else {
        layer.msg('请输入查询内容!');
    }
}