總共有兩個問題:一: 如下圖所示, 打開網頁 首先顯示的是讓你確認或取消,我想修改一下 這個提示, 但是沒有找到這個在哪里可以修改也就是說, 如果我點擊取消了, 那我就給他提示,獲取失敗等等等之類的提示二:時而談提示 能獲取到定位, 時而不彈提示,獲取不到定位 是什么原因呢。該信息,在Pc端沒有出現過問題, 在手機端 出現過問題, 但是也是小概率獲取不到。也不提示。排除了手機定位關閉的原因, 但是我這是ip 定位阿 。。下面附代碼;city(){ const geolocation = new BMap.Geolocation(); let _this = this; let inmatrix = []; // 省外基地臨時放置 geolocation.getCurrentPosition(function getinfo(position){ let city = position.address.city.replace("市",""); // 獲取城市信息 let province = position.address.province.replace("省",""); // 獲取省份信息 let locationCity = province + city; _this.$dialog.alert({ title: "提示", // 標題 message: `檢測到您當前位于【${locationCity}】`, // 內容 showCancelButton: true, // 展示取消按鈕 confirmButtonText: "省內選擇", cancelButtonText: "省外選擇" }) .then(() => { // 點擊確認 _this.matrix=[]; _this.inmatrix=[]; for(let i = 0 ; i < _this.baseLibrary.length ; i++ ) { if(_this.baseLibrary[i].text.indexOf(province) != -1 || _this.baseLibrary[i].text.indexOf(city) != -1){ _this.matrix.push(_this.baseLibrary[i]); _this.base = true; } else { _this.inmatrix.push(_this.baseLibrary[i]); } // 如果沒有定位到則提示, 顯示所有基地 if(_this.matrix == 0){ _this.$toast('您所在省份沒有下屬基地,請選擇所在基地!'); _this.baseLibrary.map( r=>{ _this.matrix.push(r); }); _this.base = true; } } }) .catch(() => { // 點擊取消 _this.inmatrix=[]; for(let i = 0 ; i < _this.baseLibrary.length ; i++ ) { if(_this.baseLibrary[i].text.indexOf(province) != -1 || _this.baseLibrary[i].text.indexOf(city) != -1){ _this.matrix.push(_this.baseLibrary[i]); _this.base = true; } else { _this.inmatrix.push(_this.baseLibrary[i]); } } _this.matrix=[];
關于百度地圖JavaScriptApi 定位問題,時行時不行。
滄海一幻覺
2019-05-19 14:01:08