当前位置: 首页 > wzjs >正文

绑定手机网站文件夹优化防控举措

绑定手机网站文件夹,优化防控举措,黄山旅游攻略 知乎,建行官网终于有时间继续Cesium系列了,这次来搞定在Cesium场景中添加最基础也是最常用的几何元素:点、线、面。 作为GIS开发中的三大基本要素,点线面几乎是每个地图应用都要用到的。在Cesium中,我们有两种主要的方式来添加这些元素&#xf…

终于有时间继续Cesium系列了,这次来搞定在Cesium场景中添加最基础也是最常用的几何元素:点、线、面。

  • 作为GIS开发中的三大基本要素,点线面几乎是每个地图应用都要用到的。
  • 在Cesium中,我们有两种主要的方式来添加这些元素:Entity API 和 Primitive API。

先简单说下这两种方式的区别,免得新手朋友们搞混:

  • Entity API:高级API,使用简单,自动管理很多细节,适合快速开发和原型制作
  • Primitive API:底层API,性能更好,控制更精细,适合大量数据和复杂场景

一般来说,刚开始学习建议从Entity入手,等熟悉了再考虑Primitive。代码中这两种方式都做了示例,让大家有个全面的了解。

<template><div id="cesiumContainer" style="width: 100%; height: 100vh;"></div>
</template><script setup>
import { onMounted } from 'vue';
import {Ion,Viewer,Cartesian3,Color,PointGraphics,PolylineGraphics,PolygonGraphics,GeometryInstance,PolylineGeometry,PolygonGeometry,Primitive,PerInstanceColorAppearance,ColorGeometryInstanceAttribute,PolylineMaterialAppearance,Material,EllipsoidSurfaceAppearance,PointPrimitiveCollection,BillboardCollection,Cartesian2
} from "cesium";
import "cesium/Build/Cesium/Widgets/widgets.css";onMounted(() => {// 设置 Cesium Ion 访问令牌Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhNmQ5NDYyNi1lZTdhLTRiYTItODFiZi1mYzNiYWNjNDFjMzgiLCJpZCI6NTk3MTIsImlhdCI6MTY2MDE4MDAyNX0.bDTaHEah0hRjUyJWz0hyxIL0Fg63awPXV26OmQ5MCdM';const viewer = new Viewer('cesiumContainer', {animation: false, // 移除动画控件timeline: false, // 移除时间轴控件geocoder: false, // 移除地理编码控件homeButton: false, // 移除主页按钮sceneModePicker: false, // 移除场景模式选择器selectionIndicator: false, // 移除选择指示器fullscreenButton: false, // 移除全屏按钮vrButton: false // 移除 VR 按钮});// ==================== 使用 Entity API 添加点线面 ====================// 1. 使用 Entity 添加点// 红色圆点 - 北京viewer.entities.add({id: 'entity-point-beijing',name: '北京 - Entity点',position: Cartesian3.fromDegrees(116.3974, 39.9093), // 经度,纬度point: new PointGraphics({pixelSize: 15, // 点的像素大小color: Color.RED, // 点的颜色outlineColor: Color.WHITE, // 边框颜色outlineWidth: 2, // 边框宽度heightReference: 0 // 高度参考(贴地)})});// 蓝色圆点 - 上海viewer.entities.add({id: 'entity-point-shanghai',name: '上海 - Entity点',position: Cartesian3.fromDegrees(121.4737, 31.2304),point: new PointGraphics({pixelSize: 20,color: Color.BLUE,outlineColor: Color.YELLOW,outlineWidth: 3})});// 2. 使用 Entity 添加线// 红色线条 - 连接北京和上海viewer.entities.add({id: 'entity-line-beijing-shanghai',name: '北京-上海连线 - Entity线',polyline: new PolylineGraphics({positions: [Cartesian3.fromDegrees(116.3974, 39.9093), // 北京Cartesian3.fromDegrees(121.4737, 31.2304)  // 上海],width: 5, // 线条宽度clampToGround: true, // 贴地显示material: Color.RED // 线条材质颜色})});// 绿色折线 - 多个点的连线viewer.entities.add({id: 'entity-polyline-multiple',name: '多点连线 - Entity折线',polyline: new PolylineGraphics({positions: [Cartesian3.fromDegrees(110, 35),Cartesian3.fromDegrees(115, 35),Cartesian3.fromDegrees(115, 40),Cartesian3.fromDegrees(120, 40),Cartesian3.fromDegrees(120, 35)],width: 8,clampToGround: true,material: Color.GREEN})});// 3. 使用 Entity 添加面// 蓝色半透明多边形viewer.entities.add({id: 'entity-polygon-blue',name: '蓝色多边形 - Entity面',polygon: new PolygonGraphics({hierarchy: [Cartesian3.fromDegrees(105, 30),Cartesian3.fromDegrees(110, 30),Cartesian3.fromDegrees(110, 35),Cartesian3.fromDegrees(105, 35)],material: Color.BLUE.withAlpha(0.5), // 半透明蓝色outline: true, // 显示边框outlineColor: Color.BLUE, // 边框颜色extrudedHeight: 50000 // 拉伸高度(米)})});// 红色多边形(带洞)viewer.entities.add({id: 'entity-polygon-with-hole',name: '带洞多边形 - Entity面',polygon: new PolygonGraphics({hierarchy: {positions: [// 外边界Cartesian3.fromDegrees(125, 30),Cartesian3.fromDegrees(135, 30),Cartesian3.fromDegrees(135, 40),Cartesian3.fromDegrees(125, 40)],holes: [// 内部洞{positions: [Cartesian3.fromDegrees(128, 33),Cartesian3.fromDegrees(132, 33),Cartesian3.fromDegrees(132, 37),Cartesian3.fromDegrees(128, 37)]}]},material: Color.RED.withAlpha(0.6),outline: true,outlineColor: Color.DARKRED})});// ==================== 使用 Primitive API 添加点线面 ====================// 4. 使用 Primitive 添加点// 创建点集合 - 使用 PointPrimitiveCollectionconst pointCollection = new PointPrimitiveCollection();// 添加黄色点pointCollection.add({position: Cartesian3.fromDegrees(100, 25), // 广州附近color: Color.YELLOW,pixelSize: 20,outlineColor: Color.BLACK,outlineWidth: 2,id: 'primitive-point-1'});// 添加紫色点pointCollection.add({position: Cartesian3.fromDegrees(103, 28), // 成都附近color: Color.PURPLE,pixelSize: 25,outlineColor: Color.WHITE,outlineWidth: 3,id: 'primitive-point-2'});// 将点集合添加到场景viewer.scene.primitives.add(pointCollection);// 5. 使用 Primitive 添加线// 创建线几何实例const polylineInstances = [new GeometryInstance({geometry: new PolylineGeometry({positions: [Cartesian3.fromDegrees(90, 20),Cartesian3.fromDegrees(95, 25),Cartesian3.fromDegrees(100, 20)],width: 10.0}),attributes: {color: ColorGeometryInstanceAttribute.fromColor(Color.ORANGE)},id: 'primitive-polyline-1'})];// 添加线Primitive到场景viewer.scene.primitives.add(new Primitive({geometryInstances: polylineInstances,appearance: new PolylineMaterialAppearance({material: Material.fromType('Color', {color: Color.ORANGE})})}));// 6. 使用 Primitive 添加面// 创建多边形几何实例const polygonInstances = [new GeometryInstance({geometry: new PolygonGeometry({polygonHierarchy: {positions: [Cartesian3.fromDegrees(85, 15),Cartesian3.fromDegrees(95, 15),Cartesian3.fromDegrees(95, 25),Cartesian3.fromDegrees(85, 25)]},extrudedHeight: 100000 // 拉伸高度}),attributes: {color: ColorGeometryInstanceAttribute.fromColor(Color.CYAN.withAlpha(0.7))},id: 'primitive-polygon-1'}),new GeometryInstance({geometry: new PolygonGeometry({polygonHierarchy: {positions: [Cartesian3.fromDegrees(75, 35),Cartesian3.fromDegrees(85, 35),Cartesian3.fromDegrees(80, 45)]}}),attributes: {color: ColorGeometryInstanceAttribute.fromColor(Color.MAGENTA.withAlpha(0.8))},id: 'primitive-polygon-2'})];// 添加面Primitive到场景viewer.scene.primitives.add(new Primitive({geometryInstances: polygonInstances,appearance: new EllipsoidSurfaceAppearance({material: Material.fromType('Color', {color: Color.CYAN.withAlpha(0.5)}),translucent: true})}));// 设置相机视角,显示所有添加的元素// 计算所有图形的边界,设置最佳观察位置// 图形分布范围:经度 75-135,纬度 15-45/*viewer.camera.setView({destination: Cartesian3.fromDegrees(105, 30, 3000000), // 经度,纬度,高度(米)orientation: {heading: 0.0, // 方向角(正北方向)pitch: -0.7,  // 俯仰角(向下看)roll: 0.0     // 翻滚角}});*/// 或者使用 flyTo 方法,自动计算最佳视角(备用方案)viewer.flyTo(viewer.entities);// ==================== 辅助功能 ====================// 点击事件处理 - 用于查看点击的实体信息viewer.cesiumWidget.screenSpaceEventHandler.setInputAction(function onLeftClick(event) {const pickedObject = viewer.scene.pick(event.position);if (pickedObject && pickedObject.id) {console.log('点击的实体:', pickedObject.id);// 如果是Entity,可以获取更多信息if (pickedObject.id.name) {console.log('实体名称:', pickedObject.id.name);}}}, 2); // 2 代表鼠标左键点击事件
});
</script><style>
/* 隐藏页面底部的 Cesium logo 和数据归属 */
.cesium-viewer .cesium-widget-credits {display: none !important; /* 隐藏整个 Cesium 控件 */
}/* 隐藏 右上角的 Imagery 和 Navigation instructions */
.cesium-viewer .cesium-viewer-toolbar {display: none !important; /* 隐藏工具栏 */
}
</style>

源码


文章转载自:

http://LKGsgDiH.dygqq.cn
http://B68d4fyw.dygqq.cn
http://k7yCC5EN.dygqq.cn
http://ywOWP4np.dygqq.cn
http://nOtQWVpG.dygqq.cn
http://RQJRVqJq.dygqq.cn
http://oESN52Qc.dygqq.cn
http://9Zz5avC7.dygqq.cn
http://rzj8jH2Z.dygqq.cn
http://gMtRJHl3.dygqq.cn
http://tlxN0o41.dygqq.cn
http://ZBrcNHuk.dygqq.cn
http://39dk0aE1.dygqq.cn
http://ire5VV7m.dygqq.cn
http://780lWLk8.dygqq.cn
http://XsrSfhlh.dygqq.cn
http://AMvNAq1W.dygqq.cn
http://ymwA7jCa.dygqq.cn
http://qhUKPKWq.dygqq.cn
http://l4yzIIpb.dygqq.cn
http://870nSFko.dygqq.cn
http://5L4hJr3h.dygqq.cn
http://aDBkOtGg.dygqq.cn
http://diw6bW8R.dygqq.cn
http://gpMTBRDL.dygqq.cn
http://x3Zv1nCD.dygqq.cn
http://z7fTzvFM.dygqq.cn
http://t6mKRju2.dygqq.cn
http://6lKJVP9C.dygqq.cn
http://jUMBDQVQ.dygqq.cn
http://www.dtcms.com/wzjs/658961.html

相关文章:

  • 口碑最好的网站建设镇江本地网站
  • 西安有什么好玩的景点seo优化
  • 购物网站模块是什么意思四川整站优化关键词排名
  • 建一个电影网站多大 数据库国内外搜索引擎大全
  • 免费机械网站模板网罗设计网站
  • 江苏缘生源建设工程有限公司网站西安市免费做网站
  • 做网站公司汉狮团队WordPress发表心情
  • 网站怎么做微信支付宝支付网站建设皖icp
  • 高米店网站建设西宁啥时候恢复正常
  • 哪个公司做企业网站好wap网站和app的区别
  • 怎样做直播网站app北京公司注册虚拟地址
  • 家庭电影网站建设flash型网站
  • 做网站好还是做安卓app好新北方app下载
  • 网站哪家做的比较好现在装宽带要多少钱
  • 网站建设详细流wordpress hook机制
  • 做网站需要的技术扬中网站建设开发
  • 投资建设网站wordpress redis 加速
  • 建立个人博客网站的流程利用php做网站
  • 网站建设选哪个微信公众号调用WordPress
  • 大兴网站建设优化seo广西城乡和建设厅网站
  • 绿色电器公司网站psd模板怎么看一个网站是否被k
  • 乐都网站建设多少钱北京代理网站备案电话
  • 鞍山网站哪家好公司网站制作设计报价
  • 网站设计与建设第一章广东网站设计品牌设计
  • 网站维护一般多少钱c2c模式是什么意思
  • 网站跳出的广告是怎么做的网站开发大全
  • 做一个回收网站怎么做个人备案的网站内容
  • 通城做网站公司wordpress目录在哪里
  • 凡客诚品官方网站首页北京广告制作公司
  • 做网站哪个编辑器好用门户网站群建设