|
@@ -181,24 +181,44 @@
|
|
|
let that = this;
|
|
|
console.log("请求定位")
|
|
|
that.loading = true
|
|
|
- uni.getLocation({
|
|
|
- type:"gcj02",
|
|
|
- success : function (res) {
|
|
|
- console.log("定位返回信息:", res);
|
|
|
- that.latitude = res.latitude;
|
|
|
- that.longitude = res.longitude;
|
|
|
- that.currentPosition.latitude = res.latitude
|
|
|
- that.currentPosition.longitude = res.longitude
|
|
|
+
|
|
|
+ if(navigator.geolocation){
|
|
|
+ //判断是否有这个对象
|
|
|
+ navigator.geolocation.getCurrentPosition(function(pos){
|
|
|
+ console.log("经度:"+pos.coords.longitude+"纬度:"+pos.coords.latitude);
|
|
|
+ that.latitude = pos.coords.latitude;
|
|
|
+ that.longitude = pos.coords.longitude;
|
|
|
+ that.currentPosition.latitude = pos.coords.latitude
|
|
|
+ that.currentPosition.longitude = pos.coords.longitude
|
|
|
that.loading = false
|
|
|
that.getNearRoadsl()
|
|
|
- },
|
|
|
- fail: function(res){
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: res,
|
|
|
- type: 'error',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: "当前系统不支持GPS API",
|
|
|
+ type: 'error',
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // uni.getLocation({
|
|
|
+ // type:"gcj02",
|
|
|
+ // success : function (res) {
|
|
|
+ // console.log("定位返回信息:", res);
|
|
|
+ // that.latitude = res.latitude;
|
|
|
+ // that.longitude = res.longitude;
|
|
|
+ // that.currentPosition.latitude = res.latitude
|
|
|
+ // that.currentPosition.longitude = res.longitude
|
|
|
+ // that.loading = false
|
|
|
+ // that.getNearRoadsl()
|
|
|
+ // },
|
|
|
+ // fail: function(res){
|
|
|
+ // this.$refs.uToast.show({
|
|
|
+ // title: res,
|
|
|
+ // type: 'error',
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 导航
|