
function ciy_chart_farm1_bg_cemap(opdata) {
    this.func = ['farm_cemap1'];
    this.lastdata = {};
    this.resize = function () {
    }
    this.setdata = function (funame, data) {
        if (!data)
            return;
        this.lastdata[funame] = data;
        if (thos.ce)
            return;
        thos.ce = new ciyearth();
        var mapset = ciyfn.tojson(data.cemap.mapjson) || {};
        mapset.domid = 'ceContainer';
        mapset.personheight = 1.8;
        mapset.flys = mapset.flys || [];
        if (mapset.flys.length == 0) {
            var height = 2000.0;
            var position = Cesium.Cartesian3.fromDegrees(tofloat(data.base.lng), tofloat(data.base.lat), height);
            mapset.flys.push({ name: '俯视', dat: JSON.stringify({ fd: position, fo: { h: Cesium.Math.toRadians(0.0), p: Cesium.Math.toRadians(-90.0), r: 0.0 } }) });
        }
        thos.ce.init(mapset);
        for (var i = 0; i < mapset.flys.length; i++) {
            var html = $5('<div>' + mapset.flys[i].name + '</div>');
            html.attr('data-dat', mapset.flys[i].dat);
            $5('.ceflys').append(html);
        }
        $5('.ceflys>div').on('click', function () {
            event.stopPropagation();
            $5('.ceflys>div').removeClass('select');
            $5(this).addClass('select');
            var dat = $5(this).attr('data-dat');
            thos.ce.flyTo(ciyfn.tojson(dat), 3);
        });
        data.base.img = '/ud/img/map1.png';
        data.base.width = 20;
        data.base.height = 27;
        data.base.autoheight = true;
        thos.ce.addmarker(data.base);
        thos.ce.ciyevent = function (type, act, data, data2) {
            if (type == 'click') {
            } else if (type == 'entity') {
                if (act == 'leftclick') {
                    console.log(data);
                    if (data.entity.ciydata && data.entity.ciydata.bind) {
                        var bds = data.entity.ciydata.bind.split('_');
                        if (bds.length != 2)
                            return;
                        if (bds[0] == 'camera') {
                            showvideo({ id: bds[1], name: data.entity.name });
                        }
                    }
                }
            } else if (type == 'control') {
                if (act == 'walk' || act == 'fly') {
                    $5('.ceflys').hide('slide', 0);
                    $5('.cecontrolpanel').show();
                    $5('.cehide').hide();

                } else if (act == 'close') {
                    $5('.ceflys').show('slide', 0.5, 'flex');
                    $5('.cecontrolpanel').hide();
                    $5('.cehide').show();
                } else if (act == 'op') {
                    var htmltip = '';
                    if (thos.ce.viewer.flags.walk)
                        htmltip += '<kbd>行走</kbd>';
                    else
                        htmltip += '<kbd>飞行</kbd>';
                    var lng = Cesium.Math.toDegrees(data.longitude);
                    var lat = Cesium.Math.toDegrees(data.latitude);
                    htmltip += '经度:' + lng.toFixed(4) + ' 纬度:' + lat.toFixed(4) + ' 海拔:' + data.height.toFixed(1) + '米';
                    if (thos.ce.lastfloorheight > -9999)
                        htmltip += ' 高程:' + thos.ce.lastfloorheight.toFixed(1) + '米';
                    htmltip += ' 档位:<code style="font-size: 1.3em;">' + thos.ce.viewer.flags.speedbet + '</code>';
                    htmltip += '　';
                    $5('.cecontrolpanel').html(htmltip);
                } else {
                    $5('.cecontrolpanel').html('');
                }
            }
        };
    }
    this.distory = function (data) {
        if (thos.ce)
            thos.ce.destroy();
        thos.ce = null;
    }


    var thos = this;
    this.ce = null;
    this.resize();
    opdata.container.append(`<div id="ceContainer"></div>
                                <div class="cecontrolpanel" style="display:none;"></div>
                                <div class="ceflys"></div>`);
}