created() {
let self = this;
self.interval = setInterval(() => {
self.time = moment().format("HH:mm:ss");
}, 1000);
const geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r) {
console.log(r)
self.lat = r.point.lat;
self.lng = r.point.lng;
self.$ls.set("lat", self.lat);
self.$ls.set("lng", self.lng);
self.getClockStatus();
var myGeo = new BMap.Geocoder({ extensions_town: true });
myGeo.getLocation(new BMap.Point(self.lng, self.lat), function(
result
) {
if (result) {
self.$ls.set("address", result.address);
console.log(result.address)
self.address = result.address;
}
});
});
},
获取的经纬度只显示到市政府,不会改变,这是什么问题
以前做的时候遇到过,你要检查:
1.接口是不是用对了
2.协议是否为https,http协议因为不安全,所以无法获取精准定位
3.如果是ios的浏览器,可以获取到定位