local.js如下
var app = getApp()
Page({
data:{
latitude:'',
longitude:''
},
getLocation:function(e) {
console.log(e)
var that = this
wx.getLocation({
type: 'wgs84', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success: function(res){
console.log(res)
that.setData({
longitude:res.longitude,
latitude:res.latitude
})
}
})
}
})
local.wxml如下
经度:
value="{{longitude}}" name="longitude">
纬度:
value="{{latitude}}" name="latitude">
app.json如下
{
"pages":[
"pages/local/local"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "定位",
"navigationBarTextStyle":"black"
}
}