準(zhǔn)備工作
需要在微信開發(fā)者平臺中注冊一個小程序賬號,微信開發(fā)者平臺官網(wǎng)如下
https://mp.weixin.qq.com/
申請流程
登錄微信開發(fā)者平臺后,在左側(cè)選項欄點擊開發(fā)-開發(fā)管理
在開發(fā)管理中點擊接口設(shè)置,在下面就可以進行地理位置權(quán)限申請了,其中wx.getFuzzyLocation接口是比較好申請的。
使用教程
編譯器:Hbuilder
運行器:微信開發(fā)者工具
首先在manifest.json文件中配置小程序的位置信息,
/* 小程序特有相關(guān) */
"mp-weixin" : {
"appid" : "wxa8e6388009466d0c",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true,
"permission" : {
"scope.userFuzzyLocation":{
"desc":"位置信息效果展示"
}
},
"requiredPrivateInfos" : [ "getFuzzyLocation" ]
},
配置manifest.json后還需要配置page.json文章來源:http://www.zghlxwxcb.cn/news/detail-526349.html
"permission":{
"scope.userFuzzyLocation":{
"desc":"位置信息效果展示"
}
}
最后就可以調(diào)用接口文章來源地址http://www.zghlxwxcb.cn/news/detail-526349.html
uni.getFuzzyLocation({
success: function(res) {
this.longitude = res.longitude
this.latitude = res.latitude
console.log(res.longitude)
console.log(res.latitude)
}
});
到了這里,關(guān)于微信小程序地理位置權(quán)限申請及使用教程的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!