1.

小程序在获取当前位置信息在地图上显示api:https://developers.weixin.qq.com/miniprogram/dev/api/wx.getLocation.html

2.

主要方法:

wx.getLocation({type:'wgs84',success(res){constlatituderes.latitudeconstlongituderes.longitude}})3.

这一步的时候,会出现在这样的提示:

4.

所以要进入app.json配置以下参考API:https://developers.weixin.qq.com/miniprogram/dev/framework/config.html#permission

5.

配置授权信息的代码

{"pages":["pages/index/index"],"permission":{"scope.userLocation":{"desc":"你的位置信息将用于小程序位置接口的效果展示"}}}6.

图片.png

7.

OK,具体代码也贴一下:

8.

index.wxml

viewbindtap"getLocation"获取当前位置信息/view9.

index.js

varappgetApp()Page({data:{},onLoad:function(options){},getLocation:function(){wx.getLocation({type:'wgs84',success(res){constlatituderes.latitudeconstlongituderes.longitudewx.openLocation({latitude:latitude,longitude:longitude,})}})},})10.

**

11.

原文作者:祈澈姑娘技术博客:https://www.jianshu.com/u/05f416aefbe1

TAG标签: 小程序在获取当前定位地点怎么查看小程序的地址如何查看小程序

http://www.xiaochengxub.com/read-96081.html