小程序開發(fā)wx.chooseLocation(OBJECT),打開地圖選擇位置
打開地圖選擇位置。
需要用戶授權 scope.userLocation
OBJECT參數說明:
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| success | Function | 是 | 接口調用成功的回調函數,返回內容詳見返回參數說明。 |
| fail | Function | 否 | 接口調用失敗的回調函數 |
| complete | Function | 否 | 接口調用結束的回調函數(調用成功、失敗都會執(zhí)行) |
success返回參數說明:
| 參數 | 說明 |
|---|---|
| name | 位置名稱 |
| address | 詳細地址 |
| latitude | 緯度,浮點數,范圍為-90~90,負數表示南緯 |
| longitude | 經度,浮點數,范圍為-180~180,負數表示西經 |
wx.openLocation(OBJECT)
?使用微信內置地圖查看位置。
需要用戶授權 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 | 否 | 接口調用結束的回調函數(調用成功、失敗都會執(zhí)行) |
示例代碼:
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
})
}
})
更多微信小程序開發(fā)教程,關注hi小程序。
第二部分:如何開通一個小商店

立即掃碼關注

多門店/直營/加盟連鎖管理系統(tǒng)