cesium添加动效弹窗
其实现原理其实就是entity+div;
var viewer=ysc.createNormalCesium("cesiumContainer",{}); var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); handler.setInputAction(function(e) { var cartesian = viewer.camera.pickEllipsoid(e.position, viewer.scene.globe.ellipsoid); var cartographic = Cesium.Cartographic.fromCartesian(cartesian); var lon = Cesium.Math.toDegrees(cartographic.longitude).toFixed(5);//四舍五入 小数点后保留五位 var lat = Cesium.Math.toDegrees(cartographic.latitude).toFixed(5);//四舍五入 小数点后保留五位 // var height = Math.ceil(viewer.camera.positionCartographic.height); //获取相机高度 if (cartesian) { /** main */ var data={ lon:lon, lat:lat, element:$("#one"),//html元素 addEntity:true,//默认为false,如果为false的话就不添加实体,后面的实体属性就不需要了,这个时候 boxHeightMax可要可不要。它代表弹窗起始点的地理坐标高度 boxHeight:20000,//中间立方体的高度 boxHeightDif:500,//中间立方体的高度增长差值,越大增长越快 boxHeightMax:40000,//中间立方体的最大高度 boxSide:10000,//立方体的边长 boxMaterial:Cesium.Color.DEEPSKYBLUE.withAlpha(0.5), circleSize:30000,//大圆的大小,小圆的大小默认为一半 }; ysc.showDynamicLayer(viewer,data,function (){ //回调函数 改变弹窗的内容; $("#one").find(".main").html("hello world!"+Math.random()*10000); }); /** main */ } },Cesium.ScreenSpaceEventType.LEFT_CLICK); viewer.camera.flyTo({ destination : Cesium.Cartesian3.fromDegrees(117.16, 32.71, 150000.0) });
详情可见 ysCesium动效弹窗