02
2018
11

微信公众号获取用户地理位置坐标asp源码下载

在做开发的时候,经常需要获取用户地址,在微信中比较省时间的方法是直接获取用户地址坐标,下面这段代码就是,直接拿去用吧!

//获取定位
//$(".getLocation").on("click", function(){
wx.getLocation({
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: function (res) {
var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
$("#p_LatLng").html(longitude+','+latitude); //用户的坐标
var url='GetAddress.asp?lat='+latitude+'&lng='+longitude;
$.ajax({
type:"get",
cache:false,
url:url,
success:function(res)
{
$("#p_Address").html(res); //中文地址

}
});
},
cancel: function (res) {
alert('用户拒绝授权获取地理位置','');
}
});
//});

=======================================
学习交流微信:18611436777

« 上一篇下一篇 »