获取目今的地理位置、速率。。当用户脱离小程序后,,,,此接口无法挪用;;;当用户点击“显示在谈天顶部”时,,,,此接口可继续挪用。。
OBJECT参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| type | String | 否 |
默以为 wgs84 返回 gps 坐标,,,,gcj02 返回可用于wx.openLocation的坐标 |
| success | Function | 是 | 接口挪用乐成的回调函数,,,,返回内容详见返回参数说明。。 |
| fail | Function | 否 | 接口挪用失败的回调函数 |
| complete | Function | 否 | 接口挪用竣事的回调函数(挪用乐成、失败都会执行) |
success返回参数说明:
| 参数 | 说明 | 最低版本 |
|---|---|---|
| latitude | 纬度,,,,浮点数,,,,规模为-90~90,,,,负数体现南纬 | |
| longitude | 经度,,,,浮点数,,,,规模为-180~180,,,,负数体现西经 | |
| speed | 速率,,,,浮点数,,,,单位m/s | |
| accuracy | 位置的准确度 | |
| altitude | 高度,,,,单位 m | 1.2.0 |
| verticalAccuracy | 笔直精度,,,,单位 m(Android 无法获。。,,返回 0) | 1.2.0 |
| horizontalAccuracy | 水平精度,,,,单位 m | 1.2.0 |
示例代码:
wx.getLocation({
type: 'wgs84',
success: function(res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
}
})
翻开地图选择位置。。
需要用户授权 scope.userLocation
OBJECT参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| success | Function | 是 | 接口挪用乐成的回调函数,,,,返回内容详见返回参数说明。。 |
| fail | Function | 否 | 接口挪用失败的回调函数 |
| complete | Function | 否 | 接口挪用竣事的回调函数(挪用乐成、失败都会执行) |
success返回参数说明:
| 参数 | 说明 |
|---|---|
| name | 位置名称 |
| address | 详细地点 |
| latitude | 纬度,,,,浮点数,,,,规模为-90~90,,,,负数体现南纬 |
| longitude | 经度,,,,浮点数,,,,规模为-180~180,,,,负数体现西经 |
?使用微信内置地图审查位置。。
需要用户授权 scope.userLocation
OBJECT参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| latitude | Float | 是 | 纬度,,,,规模为-90~90,,,,负数体现南纬 |
| longitude | Float | 是 | 经度,,,,规模为-180~180,,,,负数体现西经 |
| scale | INT | 否 | 缩放比例,,,,规模5~18,,,,默以为18 |
| name | String | 否 | 位置名 |
| address | String | 否 | 地点的详细说明 |
| success | Function | 否 | 接口挪用乐成的回调函数 |
| fail | Function | 否 | 接口挪用失败的回调函数 |
| complete | Function | 否 | 接口挪用竣事的回调函数(挪用乐成、失败都会执行) |
示例代码:
wx.getLocation({
type: 'gcj02', //返回可以用于wx.openLocation的经纬度
success: function(res) {
var latitude = res.latitude
var longitude = res.longitude
wx.openLocation({
latitude: latitude,
longitude: longitude,
scale: 28
})
}
})
bug: iOS 6.3.30 type 参数不生效,,,,只会返回 wgs84 类型的坐标信息更多微信小程序开发教程,,,,可以关注。。
KESION pp电子软件
KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。KESION 一直通过手艺立异,,,,提供产品和服务,,,,助力企业向数字化转型,,,,通过科技驱动商业刷新,,,,让商业变得更智慧!
wx.getLocation(OBJECT) 获取目今的地理位置、速率。。当用户脱离小程序后,,,,此接口无法挪用;;;当用户点击“显示在谈天顶部”时,,,,此接口可继续挪用。。 OBJECT参数说明: 参数 类型 必填
微信小程序API装备概览 系统信息——(wx.getSystemInfo、wx.getSystemInfoSync) 网络状态——(wx.getNetworkType) 重力感应——(wx.onAcc