感谢
[小白]请问wx.getLocation 可以在微信公众号开发里使用吗?// 想要通过api获取用户位置,但是目前定位不精准,只能获取当地市政府的位置。 wx.getLocation({ type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' isHighAccuracy: true, // 启用高精度 highAccuracyExpireTime: 8000, // 超时时间≥3000ms success: function (res) { let latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90 let longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。 console.log("定位结果:"+latitude+","+longitude); alert('定位结果:'+latitude+','+longitude); localStorage.setItem('gps', latitude + ',' + longitude); we.geocoderGps(latitude + ',' + longitude).then(geo => { console.log(geo); alert('返回地图定位结果:'+geo); if (geo.data.code === 200) { localStorage.setItem('address', geo.data.data); } }) } })
04-08