亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于百度地圖JavaScriptApi 定位問題,時行時不行。

關于百度地圖JavaScriptApi 定位問題,時行時不行。

滄海一幻覺 2019-05-19 14:01:08
總共有兩個問題:一: 如下圖所示, 打開網頁 首先顯示的是讓你確認或取消,我想修改一下 這個提示, 但是沒有找到這個在哪里可以修改也就是說, 如果我點擊取消了, 那我就給他提示,獲取失敗等等等之類的提示二:時而談提示 能獲取到定位, 時而不彈提示,獲取不到定位 是什么原因呢。該信息,在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=[];   
查看完整描述

2 回答

?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

  1. 彈出這個提示框,是瀏覽器自帶的,包括提示信息,你沒法修改

  2. 這個功能也是原生的,不需要依賴第三方庫可以自己寫,參考 MDN 上的使用地理位置定位

  3. ip定位一般需要依賴ip庫查詢,這塊應該也不需要依賴百度地圖

  4. 百度的 JsAPI 應該可以只用來顯示地圖和定位


查看完整回答
反對 回復 2019-05-19
  • 2 回答
  • 0 關注
  • 2326 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號