微信公众号读取微信用户经纬度为空为什么读取不出来急急,请高手帮我看一下。
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script >
wx.config({
debug: false,
appId: '<%=appId%>',
timestamp: '<%=timestamp%>',
nonceStr: '<%=nonceStr%>',
signature: '<%=signature%>',
jsApiList: ['checkJsApi', 'getLocation']
});
wx.ready(function () {
wx.checkJsApi({
jsApiList: ['getLocation'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function (res) {
var latitude;
var longitude;
var speed;
var accuracy;
var geocoder = null;
wx.getLocation({
type: 'gcj02',
success: function (res) {
latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
speed = res.speed; // 速度,以米/每秒计
accuracy = res.accuracy; // 位置精度
document.getElementById("jindu").innerHTML = latitude;
document.getElementById("weidu").value = latitude;
},
cancel: function (res) {
alert('未能获取地理位置');
}
});
}
});
});
</script>
<input type="text" id="jindu" runat="server" style="width: 1px" /> <input type="text" id="weidu" runat="server" style="width: 1px" />页面显示出来为空没有读取经纬度
</div>