1、在 index.html 中引入JS
<!-- 定位(固定链接) -->
<script src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js "></script>
2、获取当前经纬度
var geolocation = new qq.maps.Geolocation(
"你的key",
"你的key名称"
);
// 获取经纬度
geolocation.getIpLocation(this.showPosition, this.showErr);
showPosition(position) {
console.log("经度:"+position.lat);
console.log("纬度:"+position.lng);
},
showErr() {
console.log("定位失败");
this.getMyLocation(); //定位失败再请求定位
},
key 申请地址: https://lbs.qq.com/dev/console/application/mine