38 mars3d 对接地图图层 绘制点线面员

news/2024/7/10 0:47:37 标签: 3d, mars3d, vue, map

前言

这里主要是展示一下 mars3d 的一个基础的使用 

主要是设计 接入地图服务器的 卫星地图, 普通的二维地图, 增加地区标记 

基础绘制 点线面园 等等

测试用例

<template>
  <div style="width: 1920px; height:1080px;">
    <div class="mars3dClass" id="mars3dClass"></div>
  </div>

</template>

<script>

  import * as mars3d from "mars3d";

  const Cesium = mars3d.Cesium;

  export default {
    name: "mars3dMapUsage",
    components: {},
    props: {},
    data() {
      return {
        map: null,
        tdtImgLayer: null,
        labelLayer: null,
        overlay: null,
        mapOptions:{
          scene: {
            center: {"lat":31.376588,"lng":104.803391,"alt":539.5,"heading":273.6,"pitch":-40.1}
          },
          basemaps:[
            {
              type:'group',
              layers:[
                {
                  name:'3dtiles地图',
                  type:'xyz',
                  url:'/terrainresource/scmf_0to19/{z}/{x}/{y}.png',
                }
              ],
              show:true
            },
          ]
        },
      };
    },
    computed: {},
    watch: {},
    created() {

    },
    mounted() {

      this.initMap()

      // this.test01AddBoundsLayer()
      // this.test02AddDtImageLayer()
      // this.test03AddDtTDLayer()
      // this.test04AddDtLabelLayer()
      this.test11AddTerrainLayer()

      // this.test05AddImageLayer()
      // this.test06AddCircleLayer([104.065735, 30.759462])
      // this.test06AddCircleLayer([104.065735, 30.559462], "red")
      // this.test07AddBoxLayer()
      // this.test08AddCylinderLayer()
      // this.test09AddPolylineVolumeLayer()

    },
    methods: {
      initMap() {
        this.map = new mars3d.Map("mars3dClass")
        this.map.setCameraView({lng: 104.065735, lat: 30.659462, alt: 44160})
      },
      test01AddBoundsLayer() {

      },
      test02AddDtImageLayer() {
        const tdtImgLayer = new mars3d.layer.TdtLayer({
          url: "/tianditu/servlet/GoogleSatelliteMap?x={x}&y={y}&z={z}",
          zIndex: 1,
          crs: mars3d.CRS.EPSG4490
        });
        this.map.addLayer(tdtImgLayer);
      },
      test03AddDtTDLayer() {
        const tdtImgLayer = new mars3d.layer.TdtLayer({
          url: "/tianditu/servlet/GoogleTDMap?x={x}&y={y}&z={z}",
          zIndex: 1,
          crs: mars3d.CRS.EPSG4490
        });
        this.map.addLayer(tdtImgLayer);
      },
      test04AddDtLabelLayer() {
        const labelLayer = new mars3d.layer.TdtLayer({
          url: "/tianditu/servlet/GoogleTransparentMap?x={x}&y={y}&z={z}",
          zIndex: 1,
          crs: mars3d.CRS.EPSG4490
        });
        this.map.addLayer(labelLayer);
      },
      test05AddImageLayer() {
        const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
        this.map.addLayer(graphicLayer);

        const graphic = new mars3d.graphic.BillboardEntity({
          name: "贴地图标",
          position: [104.065735, 30.659462, 1000],
          style: {
            image: "/img/theme/desktop/17.jpg",
            scale: 1,
            horizontalOrigin: mars3d.Cesium.HorizontalOrigin.CENTER,
            verticalOrigin: mars3d.Cesium.VerticalOrigin.BOTTOM,
            clampToGround: true,
          },
          attr: {remark: "示例3"},
        });
        graphicLayer.addGraphic(graphic);
      },
      test06AddCircleLayer(coord, color) {
        const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
        this.map.addLayer(graphicLayer);

        const graphic = new mars3d.graphic.CircleEntity({
          position: [coord[0], coord[1], 1000],
          style: {
            radius: 1800.0,
            color: color,
            opacity: 1,
            outline: true,
            outlineWidth: 3,
            outlineColor: color,
            clampToGround: true,
          },
          popup: "直接传参的popup",
          attr: { remark: "示例6" },
        });
        graphicLayer.addGraphic(graphic);
      },
      test07AddBoxLayer() {
        const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
        this.map.addLayer(graphicLayer);

        const graphic = new mars3d.graphic.BoxEntity({
          position: new mars3d.LngLatPoint(104.165735, 30.759462, 1000),
          style: {
            dimensions: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
            fill: true,
            color: "#00ffff",
            opacity: 0.9,
            heading: 45,
            roll: 45,
            pitch: 0,
          },
          attr: { remark: "示例5" },
        });
        graphicLayer.addGraphic(graphic);
      },
      test08AddCylinderLayer() {
        const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
        this.map.addLayer(graphicLayer);

        const graphic = new mars3d.graphic.CylinderEntity({
          position: [104.265735, 30.759462, 1000],
          style: {
            length: 3000.0,
            topRadius: 0.0,
            bottomRadius: 1300.0,
            color: "#00FFFF",
            opacity: 0.7,
          },
          popup: "直接传参的popup",
          attr: { remark: "示例7" },
        });
        graphicLayer.addGraphic(graphic);
      },
      test09AddPolylineVolumeLayer() {
        const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
        this.map.addLayer(graphicLayer);

        const graphic = new mars3d.graphic.PolylineVolumeEntity({
          positions: [
            [103.965735, 30.759462, 1000],
            [103.975735, 30.81, 1000],
            [103.985735, 30.79, 1000],
          ],
          style: {
            shape: "pipeline",
            radius: 80,
            color: "#3388ff",
            opacity: 0.9,
          },
          attr: { remark: "示例11" },
        });
        graphicLayer.addGraphic(graphic);
      },
      test10SetCenter(coord, color) {
        this.map.setCameraView(coord);
      },
      test11AddTerrainLayer() {
        this.map.setCameraView({lng: 104.803391, lat: 31.376588, alt: 539.5,heading:273.6,pitch:-40.1});

        const layer = new mars3d.layer.XyzLayer({
          url: "/terrainresource/xxx/{z}/{x}/{y}.png",
          zIndex: 1,
        });
        this.map.addLayer(layer);
      }

    }
  };
</script>

<style lang="scss">
  .mars3dMapUsageClass {

  }

  .overdelay1 {
    position: absolute;
    border: 1px greenyellow solid;
    width: 200px;
    height: 50px;
  }
</style>

绘制卫星地图 + 地图标注

执行效果如下 

二维地图 + 地图标注

执行效果如下 

绘制点线面园 

执行效果如下 

卫星地图 + 地图标注 + 点线面园 

执行效果如下 

地形资源页面

执行效果如下 


http://www.niftyadmin.cn/n/5447782.html

相关文章

护网行动HW中红蓝两队各自的工作用到哪些技术?

重磅-最新网络安全&渗透测试&HVV等学习资料合集&#xff08;28份&#xff09;.zip 红队&#xff1a;主要负责模拟黑客攻击公司的网络系统&#xff0c;通过发起各种攻击&#xff0c;如漏洞利用、社会工程学攻击、恶意软件攻击、拒绝服务攻击等&#xff0c;来评估公司的…

零基础-MySQL数据库的基本操作

①MYSQL数据库基本操作-DDL 1.DDL的解释 DDL&#xff08;Data Definition Language&#xff09;&#xff0c;数据定义语言&#xff0c;包括以下内容&#xff1a; 对数据库的常用操作 对表结构的常用操作 修改表结构 2.对数据库的常用操作 功能SQL查看所有的数据库show d…

C++ Thread 源码 观后 自我感悟 整理

Thread的主要数据成员为_Thr 里面存储的是线程句柄和线程ID 先看看赋值运算符的移动构造 最开始判断线程的ID是否不为0 _STD就是使用std的域 如果线程ID不为0&#xff0c;那么就抛出异常 这里_New_val使用了完美转发&#xff0c;交换_Val和_New_val的值 _Thr _STD exchange(_…

能降低嵌入式系统功耗的三个技术

为电池寿命设计嵌入式系统已经成为许多团队重要的设计考虑因素。优化电池寿命的能力有助于降低现场维护成本&#xff0c;并确保客户不需要不断更换或充电电池&#xff0c;从而获得良好的产品体验。 团队通常使用一些标准技术来提高电池寿命&#xff0c;例如将处理器置于低功耗…

JavaEE-文件操作和IO

我们先来认识狭义上的⽂件(file)。针对硬盘这种持久化存储的I/O设备&#xff0c;当我们想要进⾏数据保存时&#xff0c;往往不是保存成⼀个整体&#xff0c;⽽是独⽴成⼀个个的单位进⾏保存&#xff0c;这个独⽴的单位就被抽象成⽂件的概念&#xff0c;就类似办公桌上的⼀份份真…

# Maven Bom 的使用

Maven Bom 的使用 文章目录 Maven Bom 的使用概述BOM特点优点缺点 MavenMaven 安装安装步骤settingx.ml常用仓库地址Idea 使用maven常见坑 SpringBoot 项目Bom使用案例项目结构主项目 zerocode-back-servezc-dependency&#xff08;第三方jar管理&#xff09;子模块zc-serve子模…

css实现的3D立体视觉效果鸡蛋动画特效

这是一个基于纯css实现的3D立体视觉效果鸡蛋动画特效&#xff0c;喜欢的朋友可以拿来使用演示动态效果 css实现的3D立体视觉效果鸡蛋动画特效

C++标准库中提供的用于处理正则表达式的类std::regex

std 是 C 标准库的命名空间&#xff0c;包含了大量标准的 C 类、函数和对象。这些类和函数提供了广泛的功能&#xff0c;包括输入输出、容器、算法、字符串处理等。 通常&#xff0c;为了使用标准库中的对象和函数&#xff0c;需在代码中包含相应的头文件&#xff0c;比如 #in…