1.首先我们要在微信公众平台申请开通getFuzzyLocation(开通位置在开发——开发管理——接口设置——接口权限里面申请开通)
2. 需要在manifest.json——源码视图里面进行声明(规则地址:地理位置接口新增与相关流程调整 | 微信开放社区)
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "wx0a868dde261b22d4",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true,
"permission" : {
},
"requiredPrivateInfos" : [ "getFuzzyLocation" ]
},
3.以上全部配置完成就可以在页面上使用uni.getFuzzyLocation
uni.getFuzzyLocation({
success: function (res) {
this.longitude = res.longitude
this.latitude = res.latitude
}
});