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

uniapp:H5定位当前省市区街道信息

高德地图api,H5定位省市区街道信息。

由于uniapp的uni.getLocation在H5不能获取到省市区街道信息,所以这里使用高德的逆地理编码接口地址接口,通过传key和当前经纬度,获取到省市区街道数据。

这里需要注意的是:**高德地图API 申请的key,必须是WEB服务端**,才可以使用逆地址编码接口。
在这里插入图片描述

uni.getLocation({type: 'gcj02', //返回可以用于uni.openLocation的经纬度geocode: true,success: (res) => {// #ifdef APP-PLUSthis.city = res.address.city;// #endifthis.latitude = res.latitude;this.longitude = res.longitude;// #ifdef H5uni.request({url: 'https://restapi.amap.com/v3/geocode/regeo', //逆地理编码接口地址。data: {key: 'eb144****************f2e0c',//location:经纬度  lng :经度  lat:纬度  location: this.longitude + ',' + this.latitude,radius: 1000,extensions: 'all',batch: false,roadlevel: 0},success: (res) => {console.log(res.data);//详细地址信息if (res.statusCode == 200 && res.data.info == 'OK') {this.city = res.data.regeocode.addressComponent.city}}});// #endif},
});

在这里插入图片描述

http://www.lryc.cn/news/103304.html

相关文章:

  • 自然语言处理从入门到应用——LangChain:提示(Prompts)-[提示模板:部分填充的提示模板和提示合成]
  • 论文笔记--GloVe: Global Vectors for Word Representation
  • day57|● 647. 回文子串 ● 516.最长回文子序列
  • docker compose.yml学习
  • 【业务功能篇55】Springboot+easyPOI 导入导出
  • 对顶堆算法
  • node.js的优点
  • golang编译跨平台
  • 关于Spring的bean的相关注解以及其简单使用方法
  • 【计算机视觉】BLIP:源代码示例demo(含源代码)
  • TWILIGHT靶场详解
  • 【案例】--GPT衍生应用案例
  • Sip网络音频对讲广播模块, sip网络寻呼话筒音频模块
  • leetcode1219. 黄金矿工(java)
  • Svelte框架入门
  • 在linux中进行arm交叉编译体验tiny6410裸机程序开发流程
  • SpringBoot实战(二十三)集成 SkyWalking
  • 深度学习实践——卷积神经网络实践:裂缝识别
  • linux | vscode | makefile | c++编译和调试
  • Spring | Bean 作用域和生命周期
  • 培训(c++题解)
  • ansible-playbook编写 lnmp 剧本
  • 需求太多处理不过来?MoSCoW模型帮你
  • Vue 3:玩一下web前端技术(六)
  • 【点云处理教程】00计算机视觉的Open3D简介
  • Windows10系统还原操作
  • Django学习笔记-模板(Template)基础
  • 使用 NVM(Node Version Manager)管理 Node.js 版本
  • (文章复现)梯级水光互补系统最大化可消纳电量期望短期优化调度模型matlab代码
  • tinkerCAD案例:24. Ruler - Measuring Lengths 标尺 -量勺