let label = this.viewer.entities.add({ id: "myEntity", position: Cesium.Cartesian3.fromDegrees(107.0, 40.0, 300.0), label: { text: '13213132', pixelOffset: new Cesium.Cartesian2(100, 0), showBackground: true, backgroundColor: Cesium.Color(0, 0, 0, .5) }, point: { color: Cesium.Color.RED, pixelSize: 50 } }) this.viewer.zoomTo(label) var handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas); handler.setInputAction(function (movement) { const position = movement.endPosition;// arg有startPosition与endPosition两个属性,即移动前后的位置信息:Cartesian2对象 const cartesian = viewer.scene.globe.pick(viewer.camera.getPickRay(position), viewer.scene);//将Cartesian2转为Cartesian3 viewer.entities.getById("myEntity").position = cartesian; }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
根据这个案例,可以做出拖动实体。
发表评论
侧栏公告
寄语
譬如朝露博客是一个分享前端知识的网站,联系方式11523518。
热评文章
标签列表
热门文章
友情链接