微信小法式定位
// 微信 - 获得位置信息 function getLocationInfo() { uni.getLocation({ type: "gcj02", success(res) { console.log('当前位置的经度:' + res.longitude); console.log('当前位置的纬度:' + res.latitude); } }) } </script> 2. 获得权限
"scope.userLocation" : { "desc" : "利用定位功用" } }, "requiredPrivateInfos": ["getLocation"]
"scope.userLocation": { "desc": "利用定位功用" } }, "requiredPrivateInfos": [ "getLocation" ],
// 微信 - 获得权限 function getAuthorizeInfo() { uni.authorize({ scope: "scope.userLocation", success(res) { getLocationInfo(); }, fail(err) { uni.showModal({ content: "检测到您没翻开获得定位功用权限,能否去设备翻开?", confirmText: "确认", cancelText: "取消", success: function(res) { if (res.confirm) { uni.openSetting({ success() { getLocationInfo(); } }) } } }) } }) } </script> 3. 获得设备信息 // 微信 - 获得设备信息 function getSettingInfo() { uni.getSetting({ success(res) { if (res.authSetting['scope.userLocation']) { getLocationInfo(); } else { getAuthorizeInfo(); } } }) } </script> 4. 获得精准定位 module.exports = QQMapWX; // 变动成 export default QQMapWX;
const tMap = new QQMapWX({ key: "00000-11111-22222-33333-44444-55555" });
type: 'gcj02', success: res => { tMap.reverseGeocoder({ location: { latitude: res.latitude, longitude: res.longitude }, success: function(res) { let result = { latitude: res.result.location.lat, longitude: res.result.location.lng, location: res.result.formatted_addresses.recommend } } }); } }); 5. 完整代码 import QQMapWX from "@/libs/qqmap-wx-jssdk.min";const tMap = new QQMapWX({ key: "00000-11111-22222-33333-44444-55555" }); // 获得地址 - 微信 export function getLocationByWeiXin() { getSettingInfo(); } // 微信 - 获得设备信息 function getSettingInfo() { uni.getSetting({ success(res) { if (res.authSetting['scope.userLocation']) { getLocationInfo(); } else { getAuthorizeInfo(); } } }) } // 微信 - 获得权限 function getAuthorizeInfo() { uni.authorize({ scope: "scope.userLocation", success(res) { getLocationInfo(); }, fail(err) { uni.showModal({ content: "检测到您没翻开获得定位功用权限,能否去设备翻开?", confirmText: "确认", cancelText: "取消", success: function(res) { if (res.confirm) { uni.openSetting({ success() { getLocationInfo(); } }) } } }) } }) } // 微信 - 获得当前经纬度 function getLocationInfo() { uni.getLocation({ type: "gcj02", success(data) { tMap.reverseGeocoder({ location: { latitude: data.latitude, longitude: data.longitude }, success: function(res) { let result = { latitude: res.result.location.lat, longitude: res.result.location.lng, location: res.result.formatted_addresses.recommend } } }); } }) } App定位
3. 完整代码 import QQMapWX from "@/libs/qqmap-wx-jssdk.min";const tMap = new QQMapWX({ key: "00000-11111-22222-33333-44444-55555" }); // 获得地址 - 腾讯 export function getLocationByApp() { uni.getLocation({ type: 'gcj02', success: res => { tMap.reverseGeocoder({ location: { latitude: res.latitude, longitude: res.longitude }, success: function(res) { let result = { latitude: res.result.location.lat, longitude: res.result.location.lng, location: res.result.formatted_addresses.recommend } resolve(result); } }); }, fail: error => { uni.showModal({ content: "检测到您没翻开获得定位功用权限,能否去设备翻开?", confirmText: "确认", cancelText: "取消", success: (res) => { if (res.confirm) { uni.getSystemInfo({ success: (sys) => { if (sys.platform == 'ios') { plus.runtime.openURL("app-settings://"); } else { let main = plus.android.runtimeMainActivity(); let Intent = plus.android.importClass("android.content.Intent"); let mIntent = new Intent('android.settings.LOCATION_SOURCE_SETTINGS'); main.startActivity(mIntent); } } }) } } }) } }); } 常见题目
{errMsg: "authorize: fail"} 处理方式: 检查微信小法式的AppID能否设置。 翻开uni-app项目标设置文件 2. 微信小法式利用定位报错 {errMsg: "getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json"}处理方式: 翻开uni-app项目标设置文件 在 "scope.userLocation" : { "desc" : "利用定位功用" } }, "requiredPrivateInfos": ["getLocation"] 将项目运转至微信开辟者工具上,翻开项目里的设置文件 在设置工具里增加红框代码。 "permission": {"scope.userLocation": { "desc": "利用定位功用" } }, "requiredPrivateInfos": [ "getLocation" ], 重新编译项目在启动, |
11月29日,华为系列手机把鸿蒙系统更新到最新版本后,取消了“辅助定位设置”的选项,
编辑导语:有些“定位方法论”充分利用了读者的“简化冲动”,可能我们在市面上接受到
定位二字,不断出现在各类圈层的朋友口中。可这个词到底是什么意思,或许没有太多人会
首先,看到这个标题,很多人可能没由的一楞,Ip地址?地位?Ip地址怎么定位?是的,没
工具/原料:1、Fake Location APPFake Location APP功能介绍:1.以ROOT环境运行,不易
某东有时候会联合发些地域性的消费券,像什么“云南消费券”、“东莞消费券”,app定
今天我们所处的移动互联网时代,手机成了每个人的生活标配。这些手机里,安装了形形色
果然是亲女儿,每次复刻的武器池都香到让人流口水。有点小失望,绫华皮肤竟然是四
定位凉凉了?定位为什么会定死?作者/李兴随着当今营销生态的变化,品牌呈现出全新的
IT之家 9 月 30 日消息,近日,百度地图发布了北斗卫星导航系统应用的最新进展,北斗
常有不少杠精说位置定位类APP打着亲情的招牌,实际上在侵犯个人隐私。但是,工具本身
你相信吗?将手机关机拔卡之后依旧可以定位,它就是一个隐形的GPS定位工具,放在以前
楚天都市报11月14日讯(记者 周丹)近日,“有人利用软件通过手机非法定位他人位置”
生活中,有很多时候都会用到手机定位找人这种找人的方法,那么,手机号怎么定位对方在
近日,有媒体报道称,华为在会员服务中心中新增了一项全新的功能——“高精度定位”,
在日常生活中,相信有不少的朋友时时刻刻想要知道自己的另一半去了哪里?可是,自己又
产品定位,归根到底是用户定位、场景定位、价值定位、价格定位4大块。想要一款产品最
为了更好地经营品牌,以及更好地瞄准目标群体、向用户传递品牌价值,品牌需要做好自身
编辑导语:前几天,华与华董事长华杉围绕《定位》这本书,提出了对定位理论的5个质疑
随着粉丝经济的增长,越来越多人意识到个人IP的高价值,很多人开始有打造个人品牌的意
声明:本站内容由网友分享或转载自互联网公开发布的内容,如有侵权请反馈到邮箱 1415941@qq.com,我们会在3个工作日内删除,加急删除请添加站长微信:15314649589
Copyright @ 2022-2044 杭州共生网络 www.gongshengyun.cn Powered by Discuz!