这篇文章主要介绍了微信小程序3种位置API的使用方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
获取位置获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用;当用户点击“显示在聊天顶部”时,此接口可继续调用。
wx.getLocation(object)
?123456789101112 获取位置 纬度:{{latitude}} 经度:{{longitude}} 速度:{{speed}} 位置的精确度:{{accuracy}} 高度:{{altitude}} 垂直精度:{{accuracy}} 水平精度:{{accuracy}} ?12345678910111213141516171819202122232425262728293031323334353637383940 //index.js//获取应用实例const app = getApp()Page({ data: { latitude: '', longitude: '', speed: '', accuracy: '', altitude:'', verticalAccuracy: '', horizontalAccuracy:'' }, onLoad: function () { }, getLocation:function(){ var _this=this; wx.getLocation({ type: 'wgs84', success: function (res) { var latitude = res.latitude var longitude = res.longitude var speed = res.speed var accuracy = res.accuracy var altitude = res.altitude var verticalAccuracy = res.verticalAccuracy var horizontalAccuracy = res.horizontalAccuracy _this.setData({ latitude: latitude, longitude: longitude, speed: speed, accuracy: accuracy, altitude: altitude, verticalAccuracy: verticalAccuracy, horizontalAccuracy: horizontalAccuracy }) } }) }})
打开地图选择位置

wx.chooseLocation(OBJECT)
打开地图选择位置。 需要用户授权 scope.userLocation
wx.chooseLocation(object)?123456789 打开地图选择位置 位置名称:{{name}} 详细地址:{{address}} 纬度:{{latitude}} 经度:{{longitude}} ?123456789101112131415161718192021222324252627282930 //index.js//获取应用实例const app = getApp()Page({ data: { name: '', address: '', latitude: '', longitude: '' }, onLoad: function () { }, getLocation:function(){ var _this=this; wx.chooseLocation({ success: function (res) { var name = res.name var addres

TAG标签: 微信模拟定位小程序定位

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