console
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello world!</title>
<style type="text/css">
#container{
width:1200px;
height:400px;
}
</style>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js"></script>
</head>
<body onload="initMap()">
<p id="location"></p>
<p id="error"></p>
<script>
var vConsole = new VConsole();
function initMap() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function (position) {
console.log( position.coords.longitude );
console.log( position.coords.latitude );
},
function (e) {
throw(e.message);
}
)
} else {
console.log('浏览器不支持定位!');
}
var geolocation = new qq.maps.Geolocation("R6MBZ-ZVHKV-CHUPX-UR3BJ-5BDCS-5QFQV", "myapp");
function onSuccess(res) {
console.log('res: ', res)
document.querySelector('#location').innerHTML = JSON.stringify(res);
}
function showErr(err, err1, err2) {
console.log('err: ', err, err1, err2)
document.querySelector('#error').innerHTML = JSON.stringify(res);
}
if (geolocation) {
var options = {timeout: 15000};
geolocation.getLocation(onSuccess, showErr, options);
} else {
errGoIndex("定位尚未加载");
}
}
</script>
</body>
</html>