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

网站如何安装dedecms超级seo助手

网站如何安装dedecms,超级seo助手,建设网站 费用,外贸公司代理注册一、高德地图 1.注册高德地图开放平台账号 (1)创建应用 这个key 第3步骤,配置到项目中locationGps.js 2.下载高德地图微信小程序插件 (1)下载地址 高德地图API | 微信小程序插件 (2)引入项目…

一、高德地图

1.注册高德地图开放平台账号

(1)创建应用

这个key 第3步骤,配置到项目中locationGps.js

2.下载高德地图微信小程序插件

(1)下载地址

高德地图API | 微信小程序插件

(2)引入项目中

3. 创建逆地理编码js文件

(1)locationGps.js

/** 使用第三方地图逆地址解析经纬度获取用户当前所在位置信息* @param {Number} lat* @param {Number} lng*/export const getUserCurrentLocationInfo = (lat, lng) => {var GDMapWX = require('../assets/GD/amap-wx.130.js');var GDMapSdk = new GDMapWX.AMapWX({key: '' // 必填  高德应用key});return new Promise((resolve, reject) => {GDMapSdk.getRegeo({location: lng + ',' + lat,success: res => {if (res && res.length > 0) {resolve(res); // 确保返回的结果是一个数组} else {reject('No data returned');}},fail: function(error) {reject(error);}});});
}

(2)存放位置

4. 前端代码

<script>
import {getUserCurrentLocationInfo
} from "@/utils/locationGps.js"; // 引入函数data(){return {latitude: 0, // 纬度,范围为-90~90,负数表示南纬,使用 gcj02 国测局坐标系longitude: 0, // 经度,范围为-180~180,负数表示西经,使用 gcj02 国测局坐标系city: '',address: '',}}methods:{// 定位getLocation() {// 使用 uni.getLocation 获取经纬度uni.getLocation({type: 'gcj02', // 使用国测局坐标系 wgs84success: (res) => {console.log('经度:', res.longitude);console.log('纬度:', res.latitude);console.log('速度:', res.speed);console.log('精度:', res.accuracy);this.latitude = res.latitude;this.longitude = res.longitude;this.getLocationInfo(res.latitude, res.longitude); },fail: (err) => {console.error('获取位置失败', err);}});},// 使用高德地图 API 进行逆地理编码getLocationInfo(lat, lng) {getUserCurrentLocationInfo(lat, lng).then((res) => {this.city = res[0].regeocodeData.addressComponent.city || res[0].regeocodeData.addressComponent.province;this.address = res[0].regeocodeData.formatted_address;console.log('城市:', this.city);console.log('详细地址:', this.address);}).catch((error) => {console.error('逆地理编码失败', error);});},},mounted() {this.getLocation();},

二、腾讯地图

1.注册腾讯地图开放平台账号

(1)创建应用



腾讯地图开放平台

(2)前端代码

将应用key配置到前端代码中

<template><view><view class="title">当前位置:<text style="font-weight: bold;">{{address}}</text></view><button @click="locationn">点击获取当前位置</button></view>
</template><script>export default {data() {return {longitude: null,latitude: null,address: ""}},onLoad() {this.location()},methods: {location() {var that=thisuni.getFuzzyLocation({success: function(res) {that.longitude=res.longitudethat.latitude=res.latitude},});},locationn() {console.log(this.longitude)console.log(this.latitude)uni.request({url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${encodeURIComponent(this.latitude)},${encodeURIComponent(this.longitude)}&key=E7XBZ-FUXC7-D22XZ-POFT7-OD5LJ-6RBAV&get_poi=1`,method: 'GET',success: (res) => {console.log(res)this.address=res.data.result.ad_info.city}})}}}
</script><style>.title {display: inline-block;margin: 20px;font-size: 20px;}
</style>

在onLoad生命周期函数中,调用getFuzzyLocation方法来获取经纬度;

再把经纬度赋给data的数据中,触发调用腾讯地图API,把我想要的值赋给address,最后在template中进行显示。

备注:

需要再项目manifest.json中,mp-weixin节点配置requiredPrivateInfos和permission。

在调用 uni.getFuzzyLocation 之前,确保请求用户授权获取位置信息,否则你会遇到如下提示:

微信开发者工具自带的getLocation就可以实现上述效果,但是申请没有getFuzzyLocation好申请,腾讯地图API中也可以根据当前IP地址来进行调用。

http://www.dinnco.com/news/53341.html

相关文章:

  • 怎么给网站添加代码网站seo关键词排名查询
  • 别墅效果图制作惠州seo网站推广
  • 客户在我这做的网站被罚品牌推广方案ppt
  • 自己搭建网站需要多少钱游戏推广赚佣金平台
  • 东丽手机网站建设刷排名的软件是什么
  • 无限元宝网页传奇首页关键词优化公司
  • 织梦网站内容自动更新企业推广方式有哪些
  • 网站建设制作汕头百度网盘在线登录入口
  • 做电商必须知道的网站百度seo推广
  • wordpress注册接口seo优化方案项目策划书
  • 代码编辑器做热点什么网站好友情链接还有用吗
  • 张家港网站设计有吗软件推广的渠道是哪里找的
  • 武夷山网站建设免费的自助建站
  • 网站建设依据搜索引擎营销特点
  • 深圳租赁住房和建设局网站民宿平台搜索量上涨
  • 网站开发用框架开发的优缺点seo免费教程
  • 淘宝优惠券网站怎么做的百度代运营公司
  • 南阳网站seo推广公司网站设计流程
  • 衡水网站建设广州百度
  • 做网站哪些我要下载百度
  • 写出网站开发的基本流程万网域名查询
  • 公司的网站建设费用属于什么费中国疾控卫生应急服装
  • 仿网站制作教学视频企业门户网站的设计与实现
  • 成都网站建设公司排名代理公司注册
  • 镇江疾控紧急提醒爱站网seo工具包
  • 哪个网站做自媒体比较好西安自动seo
  • 邓州网站建设怎样策划一个营销型网站
  • win7 网站系统怎么做鹤壁seo
  • 长沙做网站一般多少钱合适win10优化大师好用吗
  • 政府机构的网站怎么做的那么差近三年成功的营销案例