// 获取定位
// 方法一
getMyLocation() {
var geolocation = new qq.maps.Geolocation("CQPBZ-QRWCU-2RGVJ-44CGR-5WCY6-WVB5Q", "myapp_ay");
geolocation.getIpLocation(
(position) => {
console.log(position);
this.getAddress(position.lat, position.lng)
},
(err) => {
console.log("定位失败");
this.autoLocation = '安阳市';
this.getMyLocation();
},
);
// geolocation.getIpLocation(this.showPosition, this.showErr);
},
showPosition(position) {
console.log(position);
this.autoLocation = position.addr || position.city || '安阳市';
},
showErr() {
console.log("定位失败");
this.autoLocation = '安阳市';
this.getMyLocation(); //定位失败再请求定位,测试使用
},
// 方法二
getPosition(){
let vm = this
let data = {
key: "CQPBZ-QRWCU-2RGVJ-44CGR-5WCY6-WVB5Q", //申请的密钥
output: "jsonp",
};
let url = "https://apis.ma
腾讯地图获取定位
最新推荐文章于 2024-12-06 16:28:45 发布