微信模拟定位,微信小程序实现简单定位功能
微信小程序实现简单定位功能,简单易读,获取经纬度信息在pages下创建一个单页如locallocal.js如下varapp=getApp()Page({data:{latitude:'',longitude:''},getLocation:function(e){console.log(e)varthat=thiswx.getLocation({type:'wgs84',//默认为wgs84返回gps坐标,gcj02返回可用于wx.openLocation的坐标success:function(res){console.log(res)that.setData({longitude:res.longitude,latitude:res.latitude})}})}})local.wxml如下viewviewtext经度:/textinputtype="text"value="{{longitude}}"name="longitude"/inputtext纬度:/textinputtype="text"value="{{latitude}}"name="latitude"/inputviewbuttontype="primary"bindtap="getLocation"获取位置/button/view/view/view在app.json中{"pages":["pages/local/local"],"window":{"backgroundTextStyle":"light","navigationBarBackgroundColor":"#fff","navigationBarTitleText":"定位","navigationBarTextStyle":"black"}}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

