• Cesium entity click


    var url = 'http://202.107.245.51:81/user/dev/api/v2/sql?rows_per_page=40&page=0&sort_order=asc&order_by=&filter_column=&filter_value=&sql_source=null&api_key=96f34723cc3398ea5c18d3e75e3de6273a959c01&';
            var country_url = url + 'q=select * from (SELECT *,st_asgeojson(the_geom) FROM country_pop) __wrapped';
            $.ajax({
                url: country_url,
                type: 'GET',
                dataType: 'jsonp'
            })
            .done(function (data) {
                console.log(data);
                console.log(data.rows.length);
                var idArr = [];
                var cid;
                for(var i=0;i<data.rows.length;i++){
                    cid = data.rows[i].cartodb_id;
                    idArr.push(cid);
                    // console.log(cid);
                    modValue.quXian[cid] = data.rows[i];
                    var cds = eval("("+data.rows[i].st_asgeojson+")").coordinates[0][0];
                    var arr = cds[0];for(var j=1;j<cds.length;j++){ arr = arr.concat(cds[j]); }
                    var redPolygon = ONEMAP.C.viewer.entities.add({
                        name : 'BLUE polygon on surface',
                        polygon : {
                            hierarchy : Cesium.Cartesian3.fromDegreesArray(arr),
                            material : Cesium.Color.BLUE
                        },
                        id: cid
                    });
                }
                var handler = new Cesium.ScreenSpaceEventHandler(ONEMAP.C.viewer.scene.canvas);
                    handler.setInputAction(function (movement) {
                        var pick = ONEMAP.C.viewer.scene.pick(movement.position);
                        // if (Cesium.defined(pick) && (pick.id.id === cid)) {
                        if (Cesium.defined(pick) && ($.inArray(pick.id.id, idArr)>-1)) {
                            alert(modValue.quXian[pick.id.id].name);
                        }
                    }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
            })
            .fail(function () {
                console.log('获取失败')
            });

  • 相关阅读:
    最近学习的情况
    0Day – 2011.1.12[From B4A]考试终于完了
    PHP 在NetBeans中的测试[转自NetBeans.org]
    12月武汉下雪了
    Delphi下指针使用总结
    0Day – 2010.12.27[转自B4A]
    AQTime教程
    C #define理解
    C 环境的搭配
    数据结构 字符串的模式匹配
  • 原文地址:https://www.cnblogs.com/xulei1992/p/10075488.html
Copyright © 2020-2023  润新知