鸿蒙HarmonyOS 地图定位到当前位置 site查询等操作

应用服务Map使用 地图定位 地点查询及导航 周边查询 点位标记定义等

地图定位 

前提地图已经能正常显示,若不能显示请大家参考之前的那篇如何显示地图的博文

地图相关的api  

位置效果图:

 module.json5配置权限

"requestPermissions": [
      {
        "name": "ohos.permission.LOCATION",
        "reason": "$string:dependency_reason",
        "usedScene": {
          "abilities": [
            "EntryAbility"
          ],
          "when": "always"
        }
      },
      {
        "name": "ohos.permission.APPROXIMATELY_LOCATION",
        "reason": "$string:dependency_reason",
        "usedScene": {
          "abilities": [
            "EntryAbility"
          ],
          "when": "always"
        }
      },
      {
        "name": "ohos.permission.LOCATION_IN_BACKGROUND",
        "reason": "$string:dependency_reason",
        "usedScene": {
          "abilities": [
            "EntryAbility"
          ],
          "when": "always"
        }
      },
      {
        "name": "ohos.permission.INTERNET",
        "reason": "$string:dependency_reason",
        "usedScene": {
          "when": "always"
        }
      },
      {
        "name": "ohos.permission.GET_NETWORK_INFO",
        "reason": "$string:dependency_reason",
        "usedScene": {
          "when": "always"
        }
      },
      {
        "name": "ohos.permission.CAMERA",
        "reason": "$string:dependency_reason",
        "usedScene": {
          "abilities": [
            "EntryAbility"
          ],
          "when": "always"
        }
      }
    ]

确认在AGC中已配置地图权限 这里就不截图了!

MapUtil.ets

地图相关的代码 logger文件若无用则可以删除

import { map, mapCommon, navi } from '@kit.MapKit';
import { geoLocationManager } from '@kit.LocationKit';
import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import Logger from './Logger';

export class MapUtil {
  public static initializeMapWithLocation(mapController: map.MapComponentController): void {
    mapController?.setMyLocationEnabled(true);
    mapController?.setMyLocationControlsEnabled(true);
    let requestInfo: geoLocationManager.CurrentLocationRequest = {
      'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX,
      'scenario': geoLocationManager.LocationRequestScenario.UNSET,
      'maxAccuracy': 0
    };
    geoLocationManager.getCurrentLocation(requestInfo).then(async (result) => {
      let mapPosition: mapCommon.LatLng =
        await map.convertCoordinate(mapCommon.CoordinateType.WGS84, mapCommon.CoordinateType.GCJ02, result);
      AppStorage.setOrCreate('longitude', mapPosition.longitude);
      AppStorage.setOrCreate('latitude', mapPosition.latitude);
      let cameraPosition: mapCommon.CameraPosition = {
        target: mapPosition,
        zoom: 15,
        tilt: 0,
        bearing: 0
      };
      let cameraUpdate = map.newCameraPosition(cameraPosition);
      mapController?.moveCamera(cameraUpdate);
    })
  }

  public static async walkingRoutes(position: mapCommon.LatLng, myPosition?: mapCommon.LatLng) {
    let params: navi.RouteParams = {
      origins: [myPosition!],
      destination: position,
      language: 'zh_CN'
    };
    try {
      const result = await navi.getWalkingRoutes(params);
      Logger.info('naviDemo', 'getWalkingRoutes success result =' + JSON.stringify(result));
      return result;
    } catch (err) {
      Logger.error('naviDemo', 'getWalkingRoutes fail err =' + JSON.stringify(err));
    }
    return undefined;
  }

  public static async paintRoute(routeResult: navi.RouteResult, mapPolyline?: map.MapPolyline,
    mapController?: map.MapComponentController) {
    mapPolyline?.remove();
    let polylineOption: mapCommon.MapPolylineOptions = {
      points: routeResult.routes[0].overviewPolyline!,
      clickable: true,
      startCap: mapCommon.CapStyle.BUTT,
      endCap: mapCommon.CapStyle.BUTT,
      geodesic: false,
      jointType: mapCommon.JointType.BEVEL,
      visible: true,
      width: 20,
      zIndex: 10,
      gradient: false,
      color: 0xFF2970FF
    }
    mapPolyline = await mapController?.addPolyline(polylineOption);
  }

  public static async addMarker(position: mapCommon.LatLng,
    mapController?: map.MapComponentController): Promise<map.Marker | undefined> {
    let markerOptions: mapCommon.MarkerOptions = {
      position: position,
      rotation: 0,
      visible: true,
      zIndex: 0,
      alpha: 1,
      anchorU: 0.35,
      anchorV: 1,
      clickable: true,
      draggable: true,
      flat: false
    };
    return await mapController?.addMarker(markerOptions);
  }

  public static async checkPermissions(mapController?: map.MapComponentController): Promise<boolean> {
    const permissions: Permissions[] = ['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION'];
    for (let permission of permissions) {
      let grantStatus: abilityAccessCtrl.GrantStatus = await MapUtil.checkAccessToken(permission);
      if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
        mapController?.setMyLocationEnabled(true);
        mapController?.setMyLocationControlsEnabled(true);
        return true;
      }
    }
    return false;
  }

  public static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
    let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
    let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;

    let tokenId: number = 0;
    try {
      let bundleInfo: bundleManager.BundleInfo =
        await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
      let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
      tokenId = appInfo.accessTokenId;
    } catch (error) {
      let err: BusinessError = error as BusinessError;
      Logger.error(`Failed to get bundle info for self. Code is ${err.code}, message is ${err.message}`);
    }
    try {
      grantStatus = await atManager.checkAccessToken(tokenId, permission);
    } catch (error) {
      let err: BusinessError = error as BusinessError;
      Logger.error(`Failed to check access token. Code is ${err.code}, message is ${err.message}`);
    }

    return grantStatus;
  }
}

 Map.ets

import { MapComponent, mapCommon, map , sceneMap,site} from '@kit.MapKit';
import { geoLocationManager } from '@kit.LocationKit';
import { AsyncCallback ,BusinessError} from '@kit.BasicServicesKit';
import { abilityAccessCtrl,common } from '@kit.AbilityKit';
import { JSON } from '@kit.ArkTS';
import { http } from '@kit.NetworkKit';
import Logger from '../utils/Logger';

import { MapUtil } from '../utils/MapUtil';
interface testListType {
  name: string;
  latitude: string | number,
  longitude: string | number,
  color:string
}


@Entry
@Component
export  struct Map {
  private TAG = "HuaweiMapDemo";
  private mapOptions?: mapCommon.MapOptions;
  private callback?: AsyncCallback<map.MapComponentController>;
  private mapController?: map.MapComponentController;
  private mapEventManager?: map.MapEventManager;
  private marker?: map.Marker;
  // 重庆
  // @State longitude:number = 106.45952
  // @State latitude:number = 29.567283
  // 北京
  @State longitude:number = 116.4
  @State latitude:number = 39.9
  @State testList:testListType[] = []



aboutToAppear(): void {
  console.log('result0', 'result0')
    let http1 = http.createHttp();
// 替换成大家公司自己的接口地址
    let responseResult = 
http1.request('xxxxx/water/app/estuary/listRhpwk?typeId=13&riverId=1', {
      method: http.RequestMethod.GET,
      header: {
        'Content-Type': 'application/json'
      },
      readTimeout: 20000,
      connectTimeout: 10000
    });
    responseResult.then((value: http.HttpResponse) => {
      let res = JSON.stringify(value)
      let result = `${value.result}`;
      let resCode = `${value.code}`
      console.log('result1', result)

      // let resultObj: Object = JSON.parse(result)
      let resultObj: object = JSON.parse(result) as object
      console.log('result2', JSON.stringify(resultObj['data']))
      this.testList = resultObj['data']
    }).catch(() => {
    })

    // 地图初始化参数,设置地图中心点坐标及层级
    this.mapOptions = {
      position: {
        target: {
          latitude: this.latitude,
          longitude: this.longitude
        },
        zoom: 10
      },
      mapType: mapCommon.MapType.STANDARD
    };

    // 地图初始化的回调
    this.callback = async (err, mapController) => {
      if (!err) {
        // 获取地图的控制器类,用来操作地图
        this.mapController = mapController;
        this.mapEventManager = this.mapController.getEventManager();
        let callback = () => {
          console.info(this.TAG, `on-mapLoad`);
        }
        this.mapEventManager.on("mapLoad", callback);


        //确认是否已配置权限(AGC中配置) 无权限则拉起位置
        let hasPermissions = await MapUtil.checkPermissions(this.mapController);
        console.log('hasPermissions==>',hasPermissions)
        if (!hasPermissions) {
          this.requestPermissions();
        }
        if (hasPermissions) {
          let requestInfo: geoLocationManager.CurrentLocationRequest = {
            'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX,
            'scenario': geoLocationManager.LocationRequestScenario.UNSET,
            'maxAccuracy': 0
          };
          let locationChange = async (): Promise<void> => {
          };
          geoLocationManager.on('locationChange', requestInfo, locationChange);
          // 获取当前用户位置
          geoLocationManager.getCurrentLocation(requestInfo).then(async (result) => {
            let mapPosition: mapCommon.LatLng =
              await map.convertCoordinate(mapCommon.CoordinateType.WGS84, mapCommon.CoordinateType.GCJ02, result);
            AppStorage.setOrCreate('longitude', mapPosition.longitude);
            AppStorage.setOrCreate('latitude', mapPosition.latitude);
            console.log('longitude==>',mapPosition.latitude,mapPosition.longitude)
            // 飞入 类似setView flyTo camera
            let cameraPosition: mapCommon.CameraPosition = {
              target: mapPosition,
              zoom: 15,
              tilt: 0,
              bearing: 0
            };
            let cameraUpdate = map.newCameraPosition(cameraPosition);
            mapController?.animateCamera(cameraUpdate, 1000);
          })
        }


       


        //点击事件
        let callback1 = (position: mapCommon.LatLng) => {
          console.info("mapClick", `on-mapClick position = ${position.longitude} -${position.latitude}`);
        };
        this.mapEventManager.on("mapClick", callback1);
    };
  }

  // 页面每次显示时触发一次,包括路由过程、应用进入前台等场景,仅@Entry装饰的自定义组件生效
  onPageShow(): void {
    // 将地图切换到前台
    if (this.mapController !== undefined) {
      this.mapController.show();
    }
  }

  // 页面每次隐藏时触发一次,包括路由过程、应用进入后台等场景,仅@Entry装饰的自定义组件生效。
  onPageHide(): void {
    // 将地图切换到后台
    if (this.mapController !== undefined) {
      this.mapController.hide();
    }
  }

  build() {
    Stack() {
      // 调用MapComponent组件初始化地图
      MapComponent({ mapOptions: this.mapOptions, mapCallback: this.callback }).width('100%').height('100%');
      // 当前位置
      // LocationButton().onClick((event: ClickEvent, result: LocationButtonOnClickResult)=>{
      //   console.info("result " + result)
      // })


    }.height('100%')
  }
// 点击是否允许的位置权限页面
  requestPermissions(): void {
    let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
    atManager.requestPermissionsFromUser(getContext() as common.UIAbilityContext,
      ['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION'])
      .then(() => {
        this.mapController?.setMyLocationEnabled(true);
        this.mapController?.setMyLocationControlsEnabled(true);
        this.mapController?.setCompassControlsEnabled(false);
        this.mapController?.setMyLocationStyle({ displayType: mapCommon.MyLocationDisplayType.FOLLOW });
        geoLocationManager.getCurrentLocation().then(async (result) => {
          let mapPosition: mapCommon.LatLng =
            await map.convertCoordinate(mapCommon.CoordinateType.WGS84, mapCommon.CoordinateType.GCJ02, result);
          AppStorage.setOrCreate('longitude', mapPosition.longitude);
          AppStorage.setOrCreate('latitude', mapPosition.latitude);
          let cameraPosition: mapCommon.CameraPosition = {
            target: mapPosition,
            zoom: 15,
            tilt: 0,
            bearing: 0
          };
          let cameraUpdate = map.newCameraPosition(cameraPosition);
          this.mapController?.animateCamera(cameraUpdate, 1000);
        })
      })
      .catch((err: BusinessError) => {
        Logger.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`);
      })
  }
}

地点查询

 地点查询效果图:

完整示例代码:

import { MapComponent, mapCommon, map , sceneMap,site} from '@kit.MapKit';
import { geoLocationManager } from '@kit.LocationKit';
import { AsyncCallback ,BusinessError} from '@kit.BasicServicesKit';
import { abilityAccessCtrl,common } from '@kit.AbilityKit';
import { JSON } from '@kit.ArkTS';
import { http } from '@kit.NetworkKit';
import Logger from '../utils/Logger';

import { MapUtil } from '../utils/MapUtil';
interface testListType {
  name: string;
  latitude: string | number,
  longitude: string | number,
  color:string
}


@Entry
@Component
export  struct Map {
  private TAG = "HuaweiMapDemo";
  private mapOptions?: mapCommon.MapOptions;
  private callback?: AsyncCallback<map.MapComponentController>;
  private mapController?: map.MapComponentController;
  private mapEventManager?: map.MapEventManager;
  private marker?: map.Marker;
  // 重庆
  // @State longitude:number = 106.45952
  // @State latitude:number = 29.567283
  // 北京
  @State longitude:number = 116.4
  @State latitude:number = 39.9
  @State testList:testListType[] = []



aboutToAppear(): void {
  console.log('result0', 'result0')
    let http1 = http.createHttp();
    let responseResult = http1.request('xxxxx/water/app/estuary/listRhpwk?typeId=13&riverId=1', {
      method: http.RequestMethod.GET,
      header: {
        'Content-Type': 'application/json'
      },
      readTimeout: 20000,
      connectTimeout: 10000
    });
    responseResult.then((value: http.HttpResponse) => {
      let res = JSON.stringify(value)
      let result = `${value.result}`;
      let resCode = `${value.code}`
      console.log('result1', result)

      // let resultObj: Object = JSON.parse(result)
      let resultObj: object = JSON.parse(result) as object
      console.log('result2', JSON.stringify(resultObj['data']))
      this.testList = resultObj['data']
    }).catch(() => {
    })

    // 地图初始化参数,设置地图中心点坐标及层级
    this.mapOptions = {
      position: {
        target: {
          latitude: this.latitude,
          longitude: this.longitude
        },
        zoom: 10
      },
      mapType: mapCommon.MapType.STANDARD
    };

    // 地图初始化的回调
    this.callback = async (err, mapController) => {
      if (!err) {
        // 获取地图的控制器类,用来操作地图
        this.mapController = mapController;
        this.mapEventManager = this.mapController.getEventManager();
        let callback = () => {
          console.info(this.TAG, `on-mapLoad`);
        }
        this.mapEventManager.on("mapLoad", callback);


        //确认是否已配置权限(AGC中配置) 无权限则拉起位置
        let hasPermissions = await MapUtil.checkPermissions(this.mapController);
        console.log('hasPermissions==>',hasPermissions)
        if (!hasPermissions) {
          this.requestPermissions();
        }
        if (hasPermissions) {
          let requestInfo: geoLocationManager.CurrentLocationRequest = {
            'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX,
            'scenario': geoLocationManager.LocationRequestScenario.UNSET,
            'maxAccuracy': 0
          };
          let locationChange = async (): Promise<void> => {
          };
          geoLocationManager.on('locationChange', requestInfo, locationChange);
          // 获取当前用户位置
          geoLocationManager.getCurrentLocation(requestInfo).then(async (result) => {
            let mapPosition: mapCommon.LatLng =
              await map.convertCoordinate(mapCommon.CoordinateType.WGS84, mapCommon.CoordinateType.GCJ02, result);
            AppStorage.setOrCreate('longitude', mapPosition.longitude);
            AppStorage.setOrCreate('latitude', mapPosition.latitude);
            console.log('longitude==>',mapPosition.latitude,mapPosition.longitude)
            // 飞入 类似setView flyTo camera
            let cameraPosition: mapCommon.CameraPosition = {
              target: mapPosition,
              zoom: 15,
              tilt: 0,
              bearing: 0
            };
            let cameraUpdate = map.newCameraPosition(cameraPosition);
            mapController?.animateCamera(cameraUpdate, 1000);
          })
        }


        // Marker初始化参数
        for (let i = 0; i < this.testList.length - 1; i++) {
          console.log('this.testList[i].color',this.testList[i].color)
          let markerOptions: mapCommon.MarkerOptions = {
            position: {
              latitude:  this.testList[i].latitude as number,
              longitude: this.testList[i].longitude as number,
            },
            rotation: 0,
            visible: true,
            zIndex: 0,
            alpha: 1,
            anchorU: 2.5,
            anchorV: 10.5,
            clickable: true,
            draggable: true,
            flat: false,
            title:this.testList[i].name,
            icon: `icon_rhkpwk_blue.png`,
          };
          // 创建Marker
          this.marker = await this.mapController.addMarker(markerOptions);

          let callbackMarker = (marker: map.Marker) => {
            console.info(`on-markerClick marker = ${JSON.stringify(marker)}`);
            // 设置信息窗的标题
            // marker.setTitle('南京');
            // 设置信息窗的子标题
            // marker.setSnippet('华东地区');
            // 设置标记可点击
            marker.setClickable(true);
            // 设置信息窗的锚点位置
            marker.setInfoWindowAnchor(1, 1);
            // 设置信息窗可见
            marker.setInfoWindowVisible(true);

          };
          this.mapEventManager.on("markerClick", callbackMarker);
        }



        /*let initNumber = 0;
        let position: geoLocationManager.Location = {
          "latitude": this.latitude,
          "longitude":this.longitude,
          "altitude": 0,
          "accuracy": 0,
          "speed": 0,
          "timeStamp": 0,
          "direction": 0,
          "timeSinceBoot": 0,
          altitudeAccuracy: 0,
          speedAccuracy: 0,
          directionAccuracy: 0,
          uncertaintyOfTimeSinceBoot: 0,
          sourceType: 1
        };
        let count = 0;
        const intervalId = setInterval(async () => {
          position.direction = initNumber + count * 3;
          position.accuracy = initNumber + count * 100;
          position.latitude = initNumber + count * 0.1;
          position.longitude = initNumber + count * 0.1;
          this.mapController?.setMyLocation(position);
          if (count++ === 10) {
            clearInterval(intervalId);
          }
        }, 200);*/


        //点击事件
        let callback1 = (position: mapCommon.LatLng) => {
          console.info("mapClick", `on-mapClick position = ${position.longitude} -${position.latitude}`);
        };
        this.mapEventManager.on("mapClick", callback1);

        // 获取siteid 并显示地点详情 及地图导航
        let callback2 = (poi: mapCommon.Poi) => {
          console.info("poiClick", `callback1 poi = ${poi.id}`);
          let siteId:string = poi.id
          let queryLocationOptions: sceneMap.LocationQueryOptions = { siteId };
          // 拉起地点详情页
          sceneMap.queryLocation(getContext(this) as common.UIAbilityContext, queryLocationOptions).then(() => {
            console.info("QueryLocation", "Succeeded in querying location.");
          }).catch((err: BusinessError) => {
            console.error("QueryLocation", `Failed to query Location, code: ${err.code}, message: ${err.message}`);
          });
        };
        this.mapEventManager.on("poiClick", callback2);


        // 周边搜索,通过用户传入自己的位置,可以返回周边地点列表。
        let params: site.NearbySearchParams = {
          // 指定关键字
          query: "hotel",
          // 经纬度坐标
          location: {
            latitude: 31.984410259206815,
            longitude: 118.76625379397866
          },
          // 指定地理位置的范围半径
          radius: 5000,
          // 指定需要展示的poi类别
          poiTypes: ["NATIONAL_RAILWAY_STATION"],
          language: "en",
          pageIndex: 1,
          pageSize: 1
        };
        // 返回周边搜索结果
        const result = await site.nearbySearch(params);
        console.info("Succeeded in searching nearby.",JSON.stringify(result))


      }
    };
  }

  // 页面每次显示时触发一次,包括路由过程、应用进入前台等场景,仅@Entry装饰的自定义组件生效
  onPageShow(): void {
    // 将地图切换到前台
    if (this.mapController !== undefined) {
      this.mapController.show();
    }
  }

  // 页面每次隐藏时触发一次,包括路由过程、应用进入后台等场景,仅@Entry装饰的自定义组件生效。
  onPageHide(): void {
    // 将地图切换到后台
    if (this.mapController !== undefined) {
      this.mapController.hide();
    }
  }

  build() {
    Stack() {
      // 调用MapComponent组件初始化地图
      MapComponent({ mapOptions: this.mapOptions, mapCallback: this.callback }).width('100%').height('100%');
      // 当前位置
      // LocationButton().onClick((event: ClickEvent, result: LocationButtonOnClickResult)=>{
      //   console.info("result " + result)
      // })


    }.height('100%')
  }
  requestPermissions(): void {
    let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
    atManager.requestPermissionsFromUser(getContext() as common.UIAbilityContext,
      ['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION'])
      .then(() => {
        this.mapController?.setMyLocationEnabled(true);
        this.mapController?.setMyLocationControlsEnabled(true);
        this.mapController?.setCompassControlsEnabled(false);
        this.mapController?.setMyLocationStyle({ displayType: mapCommon.MyLocationDisplayType.FOLLOW });
        geoLocationManager.getCurrentLocation().then(async (result) => {
          let mapPosition: mapCommon.LatLng =
            await map.convertCoordinate(mapCommon.CoordinateType.WGS84, mapCommon.CoordinateType.GCJ02, result);
          AppStorage.setOrCreate('longitude', mapPosition.longitude);
          AppStorage.setOrCreate('latitude', mapPosition.latitude);
          let cameraPosition: mapCommon.CameraPosition = {
            target: mapPosition,
            zoom: 15,
            tilt: 0,
            bearing: 0
          };
          let cameraUpdate = map.newCameraPosition(cameraPosition);
          this.mapController?.animateCamera(cameraUpdate, 1000);
        })
      })
      .catch((err: BusinessError) => {
        Logger.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`);
      })
  }
}

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

matlab-fmincon函数做优化、optimoptions用法

定义&#xff1a; x fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) 含义&#xff1a;从 x0 开始&#xff0c;尝试在满足线性等式 Aeq*x beq 以及不等式 A*x ≤ b、 c(x) ≤ 0 和 ceq(x) 0 的情况下寻找 fun 中所述的函数的最小值点 x。对 x 中的设计变量定义一组下界…

prop校验,prop和data区别

prop:组件上注册的一些自定义属性 prop作用&#xff1a;向子组件传递数据 特点&#xff1a; 可以传递任意数量&#xff0c;任意类型的prop 父组件 &#xff08;一个个地传递比较麻烦&#xff0c;可以直接打包成一个对象传过去&#xff0c;然后通过点属性接收&#xff09; <t…

K8S containerd拉取harbor镜像

前言 接前面的环境 K8S 1.24以后开始启用docker作为CRI&#xff0c;这里用containerd拉取 参考文档 正文 vim /etc/containerd/config.toml #修改内容如下 #sandbox_image "registry.aliyuncs.com/google_containers/pause:3.10" systemd_cgroup true [plugins.…

ClickHouse的介绍、安装、数据类型

1、介绍和安装 1.1、简介 ClickHouse是俄罗斯的Yandex于2016年开源的列式存储数据库&#xff08;DBMS&#xff09;&#xff0c;使用C语言编写&#xff0c;主要用于在线分析处理查询&#xff08;OLAP&#xff09;&#xff0c;能够使用SQL查询实时生成分析数据报告。 OLAP&…

Websocket如何分块处理数据量超大的消息体

若我们服务端一次性最大处理的字节数是1M,而客户端发来了2M的数据&#xff0c;此时服务端的数据就要被切割成两次传输解码。Http协议中有分块传输&#xff0c;而在Websocket也可以分块处理超大的消息体。在jsr356标准中使用javax.websocket.MessageHandler.Partial可以分块处理…

卡尔曼滤波学习资料汇总

卡尔曼滤波学习资料汇总 其实&#xff0c;当初的目的&#xff0c;是为了写 MPU6050 的代码的&#xff0c;然后不知不觉学了那么多&#xff0c;也是因为好奇、感兴趣吧 有些还没看完&#xff0c;之后笔记也会同步更新的 学习原始材料 【卡尔曼滤波器】1_递归算法_Recursive P…

Javaweb-day13事务管理AOP

spring的事务管理&spring框架的第二大核心AOP面向切面编程 spring框架的第一大核心是前面讲的IOC控制反转 事务管理 事务回顾 概念&#xff1a;事务是一组操作的集合&#xff0c;它是一个不可分割的工作单位&#xff0c;这些操作要么同时成功&#xff0c;要么同时失败。…

JavaWeb后端开发知识储备1

目录 1.DTO/VO/PO 2.MVC架构/微服务架构 3.JWT令牌流程 4.ThreadLocal 5.接口路径/路径参数 6.自定义注解 1.DTO/VO/PO 1.1 DTO DTO 即 Data Transfer Object—— 数据传输对象&#xff0c;是用于传输数据的对象&#xff0c;通常在服务层与表现层之间传递数据&#xff…

BLE 蓝牙客户端和服务器连接

蓝牙通信在设计小型智能设备时非常普遍&#xff0c;之前一直没有使用过&#xff0c;最近使用ardunio ESP32 做了一些实验&#xff0c;做了一个收听播客的智能旋钮&#xff08;Smart Knob&#xff09;&#xff0c;它带有一个旋转编码器和两个按键。 本文介绍BLE 服务器Server和W…

海康威视和大华视频设备对接方案

目录 一、海康威视 【老版本】 【新版本】 二、大华 一、海康威视 【老版本】 URL规定&#xff1a; rtsp://username:password[ipaddress]/[videotype]/ch[number]/[streamtype] 注&#xff1a;VLC可以支持解析URL里的用户名密码&#xff0c;实际发给设备的RTSP请求不支…

STM32设计智能翻译手势识别加算法系统

目录 前言 一、本设计主要实现哪些很“开门”功能&#xff1f; 二、电路设计原理图 电路图采用Altium Designer进行设计&#xff1a; 三、实物设计图 四、程序源代码设计 五、获取资料内容 前言 在全球化的浪潮下&#xff0c;语言的多样性也为人们的交流带来了不小的挑战…

基本定时器---内/外部时钟中断

一、定时器的概念 定时器&#xff08;TIM&#xff09;&#xff0c;可以对输入的时钟信号进行计数&#xff0c;并在计数值达到设定值的时候触发中断。 STM32的定时器系统有一个最为重要的结构是时基单元&#xff0c;它由一个16位计数器&#xff0c;预分频器&#xff0c;和自动重…

Qt文件目录操作

文件目录操作相关类 Qt 为文件和目录操作提供了一些类&#xff0c;利用这些类可以方便地实现一些操作。Qt 提供的与文件和目录操作相关的类包括以下几个&#xff1a; QCoreApplication&#xff1a;用于提取应用程序路径&#xff0c;程序名等文件信息&#xff1b;QFile&#x…

.NET 通过模块和驱动收集本地EDR的工具

01阅读须知 此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等&#xff08;包括但不限于&#xff09;进行检测或维护参考&#xff0c;未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失&#xf…

css中的box-sizing,记录

border-box&#xff1a;最终高度为height&#xff0c;默认包含padding border等属性 content-box&#xff1a;box-sizing默认值&#xff0c;最终大小为heightpaddingborder 等

【AI绘画】Alpha-VLLM 的 Lumina-Next:新一代图像生成器

简介 Lumina-Next-T2I 是在 Lumina-T2I 成功基础上发展起来的尖端图像生成模型。它采用了带有 2B 参数模型的 Next-DiT 和 Gemma-2B 文本编码器&#xff0c;推理速度更快&#xff0c;生成样式更丰富&#xff0c;并增强了多语言支持。 模型架构 Lumina-Next-T2I 的生成模型建…

Redis学习 ——缓存

文章目录 一、Redis缓存的介绍二、Redis缓存问题2.1 缓存穿透2.2 缓存击穿2.3 缓存雪崩2.4 双写一致性2.5 缓存持久化RDBAOF 三、缓存数据管理3.1 数据过期策略3.2 数据淘汰策略 一、Redis缓存的介绍 我们在日常的代码编写中比较少使用到Redis&#xff0c;但是如果涉及到了比较…

【阅读记录-章节2】Build a Large Language Model (From Scratch)

目录 2.Working with text data2.1 Understanding word embeddings2.2 Tokenizing text通过一个简单的实验来理解文本的词元化概念关键概念 2.3 Converting tokens into token IDs实现分词器类&#xff08;Tokenizer Class&#xff09;应用分词器测试文本的编码与解码通过分词器…

etcd部署(基于v3.5.15)

etcd部署 单节点部署下载etcd&#xff0c;解压etcd二进制包&#xff0c;并进入解压后目录创建数据目录移动可执行文件到/usr/local/bin/目录测试版本配置systemd管理启动etcd&#xff0c;设置开机启动验证 集群部署(3节点)环境准备准备3台服务器配置3台服务器hosts配置3台服务器…

HTML5实现趣味飞船捡金币小游戏(附源码)

文章目录 1.设计来源1.1 主界面1.2 游戏中界面1.2 飞船边界框效果 2.效果和源码2.1 动态效果2.2 源代码 源码下载 作者&#xff1a;xcLeigh 文章地址&#xff1a;https://blog.csdn.net/weixin_43151418/article/details/143799554 HTML5实现趣味飞船捡金币小游戏(附源码)&…