vue获取使用封装的函数返回值

cesium/src/Utils/cesium.js

var basicAttr = {
    /**
     * 将实体从兵力组织拖拽至地图控件,落点
     * @pick1 pick2:落点坐标
    */
   screenToworld(_this,pick1,pick2){
        // 屏幕坐标转世界坐标
        var pick= new Cesium.Cartesian2(pick1,pick2);
        // var cartesian = _this.viewer.scene.globe.pick(_this.viewer.camera.getPickRay(pick),_this.viewer.scene);//3D屏幕坐标转世界坐标
        var cartesian = _this.viewer.camera.pickEllipsoid(pick, _this.viewer.scene.globe.ellipsoid);//2D屏幕坐标转世界坐标
        //世界坐标转地理坐标(经纬度)
        var Geography = _this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
        var positionParam={
            longitude:Cesium.Math.toDegrees(Geography.longitude),
            latitude:Cesium.Math.toDegrees(Geography.latitude),
            altitude:0.0
        };
        _this.viewer.entities.add({
            position : Cesium.Cartesian3.fromDegrees(positionParam.longitude, positionParam.latitude),
            billboard :{
                "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACvSURBVDhPrZDRDcMgDAU9GqN0lIzijw6SUbJJygUeNQgSqepJTyHG91LVVpwDdfxM3T9TSl1EXZvDwii471fivK73cBFFQNTT/d2KoGpfGOpSIkhUpgUMxq9DFEsWv4IXhlyCnhBFnZcFEEuYqbiUlNwWgMTdrZ3JbQFoEVG53rd8ztG9aPJMnBUQf/VFraBJeWnLS0RfjbKyLJA8FkT5seDYS1Qwyv8t0B/5C2ZmH2/eTGNNBgMmAAAAAElFTkSuQmCC",
            }
        })
        return positionParam
    },
}
export {
    basicAttr,
}

cesium/src/components/Siderbar.vue

// 将实体从兵力组织拖拽至地图控件
dragend (event) {
    if(event.clientX>200&&event.clientY>90){
        //basicAttr.screenToworld(this,event.clientX-200,event.clientY-90);
        console.log(basicAttr.screenToworld(this,event.clientX-200,event.clientY-90),"ces11")
    };
    event.dataTransfer.clearData()
}

你可能感兴趣的:(VUE.JS)