You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
69 lines
1.9 KiB
2 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1" >
|
||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||
|
<title></title>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<h3 id="menu-location">地理位置接口</h3>
|
||
|
<span class="desc">使用微信内置地图查看位置接口</span>
|
||
|
<button class="btn btn_primary"
|
||
|
id="openLocation">openLocation</button>
|
||
|
<span class="desc">获取地理位置接口</span>
|
||
|
<button class="btn btn_primary"
|
||
|
id="getLocation">getLocation</button>
|
||
|
</body>
|
||
|
|
||
|
<script>
|
||
|
//这里的配置详细可以看帮助
|
||
|
wx.config({
|
||
|
debug: false,
|
||
|
appId: 'wxf8b4f85f3a794e77',
|
||
|
timestamp: 1522828107,
|
||
|
nonceStr: 'jnShs2vgPDo6fwlY',
|
||
|
signature: '1432d01387adacbca1ce0a4d6ecf3f62363e0309',
|
||
|
jsApiList: [
|
||
|
// 所有要调用的 API 都要加到这个列表中
|
||
|
'openLocation',
|
||
|
'getLocation',
|
||
|
]
|
||
|
});
|
||
|
|
||
|
alert(wx)
|
||
|
|
||
|
wx.ready(function () {
|
||
|
alert(123)
|
||
|
// 在这里调用 API
|
||
|
// 7 地理位置接口
|
||
|
// 7.1 查看地理位置
|
||
|
document.querySelector('#openLocation').onclick = function () {
|
||
|
alert(wx.openLocation)
|
||
|
wx.openLocation({
|
||
|
latitude: 23.099994,
|
||
|
longitude: 113.324520,
|
||
|
name: 'TIT 创意园',
|
||
|
address: '广州市海珠区新港中路 397 号',
|
||
|
scale: 14,
|
||
|
infoUrl: 'http://weixin.qq.com'
|
||
|
});
|
||
|
};
|
||
|
// 7.2 获取当前地理位置
|
||
|
document.querySelector('#getLocation').onclick = function () {
|
||
|
wx.getLocation({
|
||
|
success: function (res) {
|
||
|
alert(JSON.stringify(res));
|
||
|
},
|
||
|
cancel: function (res) {
|
||
|
alert('用户拒绝授权获取地理位置');
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
</html>
|