vue - vue使用腾讯api进行定位获取,绘制地图、标点、搜索、路线规划

news2024/9/23 11:23:56

章节目录

    • 1,前言
    • 2,准备
    • 3,开始引入api
    • 4,vue组件中使用 - 获取定位
    • 5,绘制地图和标点
    • 6,关键字搜索功能
    • 7,驾车线路规划
    • 8,演示组件中的全部代码
      • 9,参考链接

1,前言

首本文主要记录一下在Vue项目里面使用腾讯地图api实现的一些功能。如:引入腾讯地图SDK、定位获取当前经纬度和详细地址、地图marker的使用、关键字搜索功能和路线规划。

我这边实现的效果图如下:
请添加图片描述

2,准备

首先要成为腾讯位置服务开发者或者使用公司提供的key值;才可以使用腾讯地图api,我这里使用的是公司提供的key值;

详细介绍见官网:https://lbs.qq.com/webApi/javascriptGL/glGuide/glBasic

3,开始引入api

在vue项目中的根路径下public文件夹的index.html中引入一些api;如下:


<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1, minimum-scale=1">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>微视频后台管理</title>
  
  	这三个文件是新引入的腾讯地图的api 注意:key值是必须要填的 是一串字符串
    <script type="text/javascript" src="https://mapapi.qq.com/web/mapComponents/geoLocation/v/geolocation.min.js"></script>
    <script type="text/javascript" src="https://map.qq.com/api/gljs?v=1.exp&libraries=service&key=这里是您的key值"></script>
    <script type="text/javascript" src="https://map.qq.com/api/gljs?v=1.exp&key=这里是您的key值"></script>

  </head>
  <body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
  </body>
</html>

4,vue组件中使用 - 获取定位

先在mounted生命周期初始化Geolocation定位组件这个类;showPosition是获取成功的回调;里面存放着当前地址的经纬度和详细地址信息;


  mounted() {
    // 1,初始化腾讯地图
    this.geolocation = new qq.maps.Geolocation('你的key值', 'myapp');
    // 2,并且开始定位
    this.getMyLocation();
  },
  
  methods:{
     // 获取当前位置
    getMyLocation() {
      this.geolocation.getLocation(this.showPosition, this.errorPosition); //开启定位
    },
    // 定位成功
    showPosition(position) {
      console.log('定位成功');
      this.longitude = position.lng;
      this.latitude = position.lat;
      this.queryParams.address = position.city + position.province + position.addr;
      // 定位成功后开始绘制地图
      this.setMap();
    },
    // 定位失败 继续尝试定位
    errorPosition(e) {
      console.log('定位失败,再次进行定位');
      // 此判断是防止多次绘制地图
      if(!this.map){
        this.getMyLocation(); 
      }
    },
  }

5,绘制地图和标点

上一步获取定位成功后我这边直接调用setMap方法进行了绘制地图的操作;并以当前为中心点进行标点;如下:
注意:绘制地图需要有一个容器(Dom节点);

/*
     *  setMap 此方法主要是绘制地图和地图标点
     *  绘制地图
     *  绘制地图演示:https://lbs.qq.com/webDemoCenter/glAPI/glMap/createMap
     *  地图标点演示:https://lbs.qq.com/webDemoCenter/glAPI/glMarker/glImagetext
     *  路线规划演示:https://lbs.qq.com/webDemoCenter/glAPI/glPolyline/polylineRoutePlan
     */
    setMap() {
	  // 防止重复绘制地图
      if(this.map) {
      	return;
      };

      // 获取存放地图的容器
      this.mapEl = document.getElementById('mapItem');
      //设置地图中心点
      this.startPosition = new TMap.LatLng(this.latitude, this.longitude);
      //定义工厂模式函数
      var myOptions = {
        rotation: 20, //设置地图旋转角度
        pitch: 30, //设置俯仰角度(0~45)
        zoom: 12, //设置地图缩放级别
        center: this.startPosition, //设置地图中心点坐标
        // mapTypeId:  window.TMap.MapTypeId.ROADMAP, //设置地图样式详情参见MapType
      };
      try {
        // 开始生成地图
        this.map = new TMap.Map(this.mapEl, myOptions);
      } catch (error) {
        console.error('error:', error);
      }
      // 地图标点官方演示请见:https://lbs.qq.com/webDemoCenter/glAPI/glMarker/glImagetext
      new TMap.MultiMarker({
        map: this.map, //指定地图容器
        styles: {
          // 点标记样式
          marker1: new TMap.MarkerStyle({
            width: 20, // 样式宽
            height: 30, // 样式高
            anchor: { x: 10, y: 30 }, // 描点位置
          }),
        },
        // 点标记数据数组
        geometries: [
          {
            id: 'demo',
            styleId: 'marker1', // 和上面styles里面的marker1 向对应
            position: new TMap.LatLng(this.latitude, this.longitude), // 标点的位置
            properties: {
              title: 'marker',
            },
          },
        ],
      });
    },

6,关键字搜索功能

输入地址然后点击搜索按钮进行搜索;如下图:
注意:搜索到的地址列表(searchList )然后使用抽屉组件并通过列表显示出来;点击每一项可以获取它的详细地址和经纬度信息;

   /* 点击搜索 搜索地址列表
     * 官方演示地址为:https://lbs.qq.com/webDemoCenter/glAPI/glServiceLib/suggestion
     */
    onSearch() {
      this.searchItem = new TMap.service.Search({ pageSize: 10 });
      // 搜索类
      this.suggest = new TMap.service.Suggestion({
        pageSize: 10, // 返回结果每页条目数
        region: this.city, // 限制城市范围
        regionFix: true, // 搜索无结果时是否固定在当前城市
      });
      if (this.onSearchValue) {
        // 请求腾讯地图接口
        this.suggest.getSuggestions({ keyword: this.onSearchValue, location: this.map.getCenter() }).then((result) => {
          this.searchList = result.data;
          if (typeof this.searchList == 'object') {
            this.souShow = true;
          }
        });
      } else {
        Toast('请输入地点再进行搜索!');
      }
    },

在这里插入图片描述

7,驾车线路规划

线路规划需要有起点和终点的经纬度;起点就是当前定位的经纬度,终点就是用户选择的地址的经纬度;方法如下:

    /* 路线规划方法  
    * 参数:前两个参数是起点的经纬度  后两个参数是终点的经纬度
    */
    goToThere(startLat,startLng,endLat,endLng) {
      let startPosition = new TMap.LatLng(startLat, startLng); // 路线规划起点
      let endPosition = new TMap.LatLng(endLat, endLng); // 路线规划起点
      // 然后开始规划路线
      this.destination.marker = new TMap.MultiMarker({
        // 创造MultiMarker创建起点和终点的标点样式
        id: 'marker-layer',
        map: this.map,// 使用之前已经绘制好的地图 进行起点和终点的标点
        styles: {
          start: new TMap.MarkerStyle({
            width: 25,
            height: 35,
            anchor: { x: 16, y: 32 },
            src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/start.png',
          }),
          end: new TMap.MarkerStyle({
            width: 25,
            height: 35,
            anchor: { x: 16, y: 32 },
            src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/end.png',
          }),
        },
         //点标记数据数组
        geometries: [
          {
            id: 'start',
            styleId: 'start',
            position:startPosition,
          },
          {
            id: 'end',
            styleId: 'end',
            position: endPosition,
          },
        ],
      });

      /* 
      驾车路线规划链接:https://lbs.qq.com/webDemoCenter/glAPI/glServiceLib/driving
      路线规划演示:https://lbs.qq.com/webDemoCenter/glAPI/glPolyline/polylineRoutePlan
      */
      //新建一个驾车路线规划类
      this.destination.driving = new TMap.service.Driving({
        mp: false, // 是否返回多方案
        policy: 'PICKUP,NAV_POINT_FIRST', // 规划策略
      });

      this.destination.driving.search({ from: startPosition, to: endPosition }).then((result) => {
        // 搜索路径 案例这边展示的是第一个中情况
        // result.result.routes[0].steps.forEach((step, index) => {
        //   document.getElementById('instruction').innerHTML += `<p>${index + 1}. ${step.instruction}</p>`;
        // });

        // 展示路线引导  有可能是多条路线的展示
        this.queryParams.routesList = JSON.stringify(result.result.routes);
        result.result.routes.map((item, index) => {
          this.displayPolyline(item.polyline, index);
        });
        // 关闭抽屉
        this.souShow = false;
      });
    },

    // 绘制路径折线样式
    displayPolyline(pl, num) {
      // 第一次进来这个判断是不成立的
      if (this.polylineLayer) {
        // updateGeometries 这个方法是更新图层
        this.polylineLayer.updateGeometries([
          {
            id: `p_${num}`,
            styleId: `style_${num}`, //和下面的styleID一一对应
            paths: pl,
          },
        ]);
      } else {
        // TMap.MultiPolyline  此方法用来构建折线 (地图线路规划)
        this.polylineLayer = new TMap.MultiPolyline({
          id: 'polyline-layer',
          map: this.map,
          styles: {
            style_0: new TMap.PolylineStyle({
              color: '#11CA53', //线填充色
              width: 6, //折线宽度
              borderWidth: 0, //边线宽度
              borderColor: '#11CA53', //边线颜色
              lineCap: 'round', //线端头方式
            }),
            style_1: new TMap.PolylineStyle({
              color: '#3777FF',
              width: 6,
              borderWidth: 0,
              borderColor: '#3777FF',
              lineCap: 'round',
            }),
            style_2: new TMap.PolylineStyle({
              color: '#CC0000', //线填充色
              width: 6, //折线宽度
              borderWidth: 0, //边线宽度
              borderColor: '#CC0000', //边线颜色
              lineCap: 'round', //线端头方式
            }),
          },
          geometries: [
            {
              id: `p_0`,
              styleId: `style_0`,
              paths: pl,
            },
          ],
        });
      }
    },

注意:

下面是此案例的全部代码,包括template和data里面的数据,此案例只是介绍腾讯地图api的一些简单使用,想要了解更多请参考官方文档;参考文档我放到最后面了;

8,演示组件中的全部代码

<template>
  <div class="app">
    <div class="content">
      <!-- 导航栏 -->
      <van-nav-bar title="测试腾讯地图" left-text="返回" left-arrow>
        <template #right>
          <van-icon name="search" size="18" />
        </template>
      </van-nav-bar>

      <!-- 获取当前所在位置 -->
      <van-field v-model="queryParams.address" rows="1" autosize clearable readonly right-icon="location-o" type="textarea" label="当前所在位置" placeholder="" input-align="right" />
      <!-- 搜索地址 -->
      <van-search v-model="onSearchValue" show-action label="地址" placeholder="请输入搜索关键词">
        <template #action>
          <div @click="onSearch">搜索</div>
        </template>
      </van-search>
      <!-- 展示地图用的 -->
      <div id="mapItem"></div>
    </div>
    <!-- 下方展示地图列表的抽屉 -->
    <van-popup v-model="souShow" position="bottom" :style="{ height: '40%' }">
      <div class="list-main">
        <div class="list-one" v-for="(item,index) in searchList" :key="index" @click="currentItem(item)">
          <div class="one-left">
            <div class="title">{{ item.title }}</div>
            <div class="text">{{ item.address }}</div>
          </div>
          <div class="one-right">
            <van-icon name="guide-o" />
          </div>
        </div>
      </div>
    </van-popup>
    <canvas id="canvasCamera" :height="Height"></canvas>
  </div>
</template>
<script>
import { Toast } from 'vant';
export default {
  directives: {},
  components: {},
  data() {
    return {
      queryParams: {
        address: '', //当前所在位置
      },
      geolocation: null, // 地图对象
      onSearchValue: '徐家汇', // 你到达的位置 也就是搜索框输入的地点
      //这两个是经纬度坐标 
      longitude: null, // 121.548752
      latitude: null, // 31.227493
      //地图绘制对象
      map: null,
      // 当前城市
      city: '上海',
      // 地图的中心点
      startPosition: null,
      // 存放地图的容器对象
      mapEl: null,
      // 搜素地图的列表
      searchList: null,
      // 控制抽屉的显示于隐藏
      souShow: false,
      // 地图折线
      polylineLayer: null,
      suggest: null,
      // 路线规划相关信息
      destination: {
        marker: null, //地图规划
        driving: null, //驾车规划
      },
      Height:400,
    };
  },
  mounted() {
    // 1,初始化腾讯地图
    this.geolocation = new qq.maps.Geolocation('V6VBZ-KD2OW-ATORL-RRKFW-QICF2-C3B7H', 'myapp');
    // 2,并且开始定位
    this.getMyLocation();
  },
  methods: {
    // 获取当前位置
    getMyLocation() {
      this.geolocation.getLocation(this.showPosition, this.errorPosition); //开启定位
    },
    // 定位成功
    showPosition(position) {
      console.log('定位成功');
      this.longitude = position.lng;
      this.latitude = position.lat;
      this.queryParams.address = position.city + position.province + position.addr;
      // 定位成功后开始绘制地图
      this.setMap();
    },
    // 定位失败 继续尝试定位
    errorPosition(e) {
      console.log('定位失败,再次进行定位');
      // 此判断是防止多次绘制地图
      if(!this.map){
        this.getMyLocation(); 
      }
    },

    /* 点击搜索中的其中一项 item的location对象里面有 此项的经纬度 */
    currentItem(item) {
      // 前两个参数是起点的经纬度  后两个参数是终点的经纬度
      this.goToThere(this.latitude,this.longitude,item.location.lat,item.location.lng)
    },

    /* 点击搜索 搜索地址列表
     * 官方演示地址为:https://lbs.qq.com/webDemoCenter/glAPI/glServiceLib/suggestion
     */
    onSearch() {
      this.searchItem = new TMap.service.Search({ pageSize: 10 });
      // 搜索类
      this.suggest = new TMap.service.Suggestion({
        pageSize: 10, // 返回结果每页条目数
        region: this.city, // 限制城市范围
        regionFix: true, // 搜索无结果时是否固定在当前城市
      });
      if (this.onSearchValue) {
        // 请求腾讯地图接口
        this.suggest.getSuggestions({ keyword: this.onSearchValue, location: this.map.getCenter() }).then((result) => {
          this.searchList = result.data;
          if (typeof this.searchList == 'object') {
            this.souShow = true;
          }
        });
      } else {
        Toast('请输入地点再进行搜索!');
      }
    },

    // 这两个是展示模式
    change2D() {
      this.map.setViewMode('2D');
    },
    change3D() {
      this.map.setViewMode('3D');
      this.map.setPitch(70);
    },

    /*
     *  setMap 此方法主要是绘制地图和地图标点
     *  绘制地图
     *  绘制地图演示:https://lbs.qq.com/webDemoCenter/glAPI/glMap/createMap
     *  地图标点演示:https://lbs.qq.com/webDemoCenter/glAPI/glMarker/glImagetext
     *  路线规划演示:https://lbs.qq.com/webDemoCenter/glAPI/glPolyline/polylineRoutePlan
     */
    setMap() {

      if(this.map) return; // 防止重复绘制地图

      // 获取存放地图的容器
      this.mapEl = document.getElementById('mapItem');
      //设置地图中心点
      this.startPosition = new TMap.LatLng(this.latitude, this.longitude);
      //定义工厂模式函数
      var myOptions = {
        rotation: 20, //设置地图旋转角度
        pitch: 30, //设置俯仰角度(0~45)
        zoom: 12, //设置地图缩放级别
        center: this.startPosition, //设置地图中心点坐标
        // mapTypeId:  window.TMap.MapTypeId.ROADMAP, //设置地图样式详情参见MapType
      };

      try {
        // 开始生成地图
        this.map = new TMap.Map(this.mapEl, myOptions);
      } catch (error) {
        console.error('error:', error);
      }

      // 地图标点官方演示请见:https://lbs.qq.com/webDemoCenter/glAPI/glMarker/glImagetext
      new TMap.MultiMarker({
        map: this.map, //指定地图容器
        styles: {
          // 点标记样式
          marker1: new TMap.MarkerStyle({
            width: 20, // 样式宽
            height: 30, // 样式高
            anchor: { x: 10, y: 30 }, // 描点位置
          }),
        },
        // 点标记数据数组
        geometries: [
          {
            id: 'demo',
            styleId: 'marker1', // 和上面styles里面的marker1 向对应
            position: new TMap.LatLng(this.latitude, this.longitude), // 标点的位置
            properties: {
              title: 'marker',
            },
          },
        ],
      });
    },

    /* 路线规划方法  
    * 参数:前两个参数是起点的经纬度  后两个参数是终点的经纬度
    */
    goToThere(startLat,startLng,endLat,endLng) {
      let startPosition = new TMap.LatLng(startLat, startLng); // 路线规划起点
      let endPosition = new TMap.LatLng(endLat, endLng); // 路线规划起点
      // 然后开始规划路线
      this.destination.marker = new TMap.MultiMarker({
        // 创造MultiMarker创建起点和终点的标点样式
        id: 'marker-layer',
        map: this.map,// 使用之前已经绘制好的地图 进行起点和终点的标点
        styles: {
          start: new TMap.MarkerStyle({
            width: 25,
            height: 35,
            anchor: { x: 16, y: 32 },
            src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/start.png',
          }),
          end: new TMap.MarkerStyle({
            width: 25,
            height: 35,
            anchor: { x: 16, y: 32 },
            src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/end.png',
          }),
        },
         //点标记数据数组
        geometries: [
          {
            id: 'start',
            styleId: 'start',
            position:startPosition,
          },
          {
            id: 'end',
            styleId: 'end',
            position: endPosition,
          },
        ],
      });

      /* 
      驾车路线规划链接:https://lbs.qq.com/webDemoCenter/glAPI/glServiceLib/driving
      路线规划演示:https://lbs.qq.com/webDemoCenter/glAPI/glPolyline/polylineRoutePlan
      */
      //新建一个驾车路线规划类
      this.destination.driving = new TMap.service.Driving({
        mp: false, // 是否返回多方案
        policy: 'PICKUP,NAV_POINT_FIRST', // 规划策略
      });

      this.destination.driving.search({ from: startPosition, to: endPosition }).then((result) => {
        // 搜索路径 案例这边展示的是第一个中情况
        // result.result.routes[0].steps.forEach((step, index) => {
        //   document.getElementById('instruction').innerHTML += `<p>${index + 1}. ${step.instruction}</p>`;
        // });

        // 展示路线引导  有可能是多条路线的展示
        this.queryParams.routesList = JSON.stringify(result.result.routes);
        result.result.routes.map((item, index) => {
          this.displayPolyline(item.polyline, index);
        });
        // 关闭抽屉
        this.souShow = false;
      });
    },

    // 绘制路径折线
    displayPolyline(pl, num) {
      // 第一次进来这个判断是不成立的
      if (this.polylineLayer) {
        // updateGeometries 这个方法是更新图层
        this.polylineLayer.updateGeometries([
          {
            id: `p_${num}`,
            styleId: `style_${num}`, //和下面的styleID一一对应
            paths: pl,
          },
        ]);
      } else {
        // TMap.MultiPolyline  此方法用来构建折线 (地图线路规划)
        this.polylineLayer = new TMap.MultiPolyline({
          id: 'polyline-layer',
          map: this.map,
          styles: {
            style_0: new TMap.PolylineStyle({
              color: '#11CA53', //线填充色
              width: 6, //折线宽度
              borderWidth: 0, //边线宽度
              borderColor: '#11CA53', //边线颜色
              lineCap: 'round', //线端头方式
            }),
            style_1: new TMap.PolylineStyle({
              color: '#3777FF',
              width: 6,
              borderWidth: 0,
              borderColor: '#3777FF',
              lineCap: 'round',
            }),
            style_2: new TMap.PolylineStyle({
              color: '#CC0000', //线填充色
              width: 6, //折线宽度
              borderWidth: 0, //边线宽度
              borderColor: '#CC0000', //边线颜色
              lineCap: 'round', //线端头方式
            }),
          },
          geometries: [
            {
              id: `p_0`,
              styleId: `style_0`,
              paths: pl,
            },
          ],
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
#mapItem {
  /*地图(容器)显示大小*/
  width: 100%;
  height: 400px;
}

// 搜索列表的样式
.list-main {
  box-sizing: border-box;
  padding: 10px 20px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  .list-one {
    width: 100%;
    padding: 10px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    .one-left {
      max-width: 70%;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      .title {
        color: #000;
      }
      .text {
        color: #666;
        margin-top: 5px;
      }
    }
    .one-right {
      width: 50px;
    }
  }
}

</style>

9,参考链接

[1]绘制地图演示: https://lbs.qq.com/webDemoCenter/glAPI/glMap/createMap

[2]地图标点演示: https://lbs.qq.com/webDemoCenter/glAPI/glMarker/glImagetext

[3]路线规划演示: https://lbs.qq.com/webDemoCenter/glAPI/glPolyline/polylineRoutePlan

[4]驾车路线规划链接: https://lbs.qq.com/webDemoCenter/glAPI/glServiceLib/driving

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/400794.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Vue项目本地开发集成引入https

问题描述 本地项目开发中用到的接口是https &#xff0c;本地http会请求不到数据 案例使用采用的vue-cli开发&#xff0c;所以需要针对这两种方式启动https 问题处理 1.首先是需要配置一个证书,使用mkcert 进行配置证书 2.在vue-cli 中进行修改package.json、vue.config.js 中进…

Leetcode.828 统计子串中的唯一字符

题目链接 Leetcode.828 统计子串中的唯一字符 Rating &#xff1a; 2034 题目描述 我们定义了一个函数 countUniqueChars(s)来统计字符串 s中的唯一字符&#xff0c;并返回唯一字符的个数。 例如&#xff1a;s "LEETCODE"&#xff0c;则其中 "L", "…

【Mysql】查询数据库,行转列,mapper.xml中查询条件的写法

目录 一、用mysql脚本建表二、现有以下三个实体对应三张表&#xff0c;其关联关系如下三、行转列的sql语句四、对应的mapper.xml写法五、输入某一关键字&#xff0c;查找车牌号或车名包含该关键字的车辆用or六、总结&#xff1a;用GROUP_CONCAT实现行转列一、用mysql脚本建表 …

compose系列教程-6.实现图文列表,添加点击事件

每个行添加点击事件&#xff0c;可以使用Clickable组件。在Clickable组件的onClick参数中&#xff0c;您可以指定要在用户单击行时执行的操作。下面是一个示例代码&#xff1a; Composable fun ImageTextList(imageTextList: List<ImageTextItem>, onItemClick: (ImageTe…

机器学习学习记录1:基本术语和假设空间

基本术语机器学习正是这样一门学科&#xff0c;它致力于研究如何通过计算的手段&#xff0c;利用经 验来玫善系统自身的性能在计算机系统中&#xff0c;"经验"通常以"数据"形式存 在&#xff0c;因此&#xff0c;机器学习所研究的主要内容&#xff0c;是关…

数据仓库的设计思想

数据仓库设计 知识点01&#xff1a;设计大纲与学习目标 #内容大纲1、数据仓库基础知识&#xff08;回顾&#xff09;什么是数仓为什么有数仓数仓的特点是什么OLTP和OLAP系统区别&#xff08;数据库和数仓的区别&#xff09;2、数仓系统的架构与核心流程核心1&#xff1a;ETL核…

mybatis(二)

mybatis练习---2种方式 能够使用映射配置文件实现CRUD操作 能够使用注解实现CRUD操作 配置文件CRUD就是把sql语句写到配置文件中&#xff0c;注解CRUD就是吧sql语句写到注解上。 一、配置文件实现CRUD 如上图所示产品原型&#xff0c;里面包含了品牌数据的 查询 、 按条件查…

使用ControlNet 控制 Stable Diffusion

本文将要介绍整合HuggingFace的diffusers 包和ControlNet调节生成文本到图像&#xff0c;可以更好地控制文本到图像的生成 ControlNet是一种通过添加额外条件来控制扩散模型的神经网络结构。它提供了一种增强稳定扩散的方法&#xff0c;在文本到图像生成过程中使用条件输入&…

【工具使用】STM32CubeMX-基础使用篇

一、概述 无论是新手还是大佬&#xff0c;基于STM32单片机的开发&#xff0c;使用STM32CubeMX都是可以极大提升开发效率的&#xff0c;并且其界面化的开发&#xff0c;也大大降低了新手对STM32单片机的开发门槛。     本文主要面向初次接触STM32CubeMX的同学&#xff0c;大…

垃圾回收:垃圾数据如何自动回收

有些数据被使用之后&#xff0c;可能就不再需要了&#xff0c;我们把这种数据称为垃圾数据。如果这些垃圾数据一直保存在内存中&#xff0c;那么内存会越用越多&#xff0c;所以我们需要对这些垃圾数据进行回收&#xff0c;以释放有限的内存空间 不同语言的垃圾回收策略 通常…

「中华田园敏捷开发」,是老板无能还是程序员无力?

敏捷开发一直都是无数程序员的追求&#xff0c;也被被视为“开发者的福音”&#xff0c;但显然敏捷开发在中国落地的专业度还不够&#xff0c;以至于出现了“中华田园敏捷”的说法&#xff0c;什么叫“中华田园敏捷开发”&#xff1f; 简单点说&#xff1a;中华田园敏捷开发的…

异常(C++)

文章目录1. 概念1.1 C语言处理错误机制1.2 C异常机制throw表达式try...catch语句例子2. 抛出异常2.1 栈展开栈展开的例子2.2 栈展开过程中对象被自动销毁2.3 析构函数与异常内存泄漏2.4 异常对象3. 捕获异常3.1 捕获子类异常3.2 异常的重新抛出4. 异常安全4.2 例子不抛出异常保…

VIT(vision transformer)onnx模型解析

背景&#xff1a;transformer在CV领域的应用论文下载链接&#xff1a;https://arxiv.org/abs/2010.11929Pytorch实现代码&#xff1a; pytorch_classification/vision_transformer(太阳花的小绿豆博主实现的代码)有一些大神在研究关于CNNtransformer或者纯用transformer实现。原…

北邮22信通:你是不是在looking for……那串代码?(2)第三章单链表

相信有了第二章顺序表的基础&#xff0c;小伙伴们学习第三章链表应该会轻松一点吧 目录 类模板下的单链表 1.1书上干净完整代码&#xff08;无增改、适合自己动手实验&#xff09; 1.2对书上代码的完善和对一些问题的验证和解释代码 1.补全一个函数&#xff1a; 2.this指…

荧光染料IR 825叠氮IR825 N3,IR-825 azide,IR-825叠氮 科研试剂

产品描述&#xff1a;IR-825 N3含有叠氮基团&#xff0c;IR-825是一种近红外染料&#xff08;NIR&#xff09;&#xff0c;IR-825在封装成纳米颗粒后&#xff0c;可能用于cancer光热和光动力 。叠氮化物基团可以参与铜催化的与炔部分的点击化学反应。西安凯新生物科技有限公司近…

基于多任务融合的圣女果采摘识别算法研究

基于多任务融合的圣女果采摘识别算法研究 1、简介 本文主要解决圣女果生产销售环节中&#xff0c;现有的流程是采摘成熟的圣女果&#xff0c;再对采摘下的果实进行单独的品质分级&#xff0c;不仅费时费力&#xff0c;而且多增加一个环节&#xff0c;也增加了对果实的二次伤害…

Oracle 19c之RPM安装

19c的RPM包下载链接&#xff0c; https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html 可以看到&#xff0c;19c开始支持企业版本的RPM&#xff0c;容量是2.5GB&#xff0c; 使用手工方式&#xff0c;通过RPM安装19c数据库&#xff0c;只需要两步操…

汽车零部件行业MES解决方案,实现生产全过程监控

行业背景 汽车汽配行业是中国国民经济的支柱产业&#xff0c;涉及的工艺包括压铸、冲压、注塑、机加、焊接、电子、喷涂、电镀、热处理、检测、装配等。 公安部数据显示&#xff0c;平均每百户家庭拥有汽车达到60辆。广阔的市场为行业带来大量需求的同时也带来了激烈的市场竞…

【Linux】网络入门

&#x1f387;Linux&#xff1a; 博客主页&#xff1a;一起去看日落吗分享博主的在Linux中学习到的知识和遇到的问题博主的能力有限&#xff0c;出现错误希望大家不吝赐教分享给大家一句我很喜欢的话&#xff1a; 看似不起波澜的日复一日&#xff0c;一定会在某一天让你看见坚持…

栈和队列详细讲解+算法动画

栈和队列 栈stack 栈也是一种线性结构相比数组&#xff0c;栈对应的操作数数组的子集只能从一端添加元素&#xff0c;也只能从一端取出元素这一端称为栈顶 栈是一种后进先出的数据结构Last in Firt out(LIFO)在计算机的世界里&#xff0c;栈拥有者不可思议的作用 栈的应用 …