2016-11-28 44 views
11

我通過navigator.geolocation請求用戶的地理位置,但我越來越拋出的錯誤:地理位置 - 在「https://www.googleapis.com/」網絡位置提供:返回錯誤代碼400

Network location provider at ' https://www.googleapis.com/ ' : Returned error code 400.

在Chrome 54.0.2840.98上發生此錯誤。這對Firefox 50.0沒有問題。我正在與http-server

這裏的本地服務器的功能:

_getLocation: function() { 
    if (!navigator.geolocation) { 
     alert('Geolocation is not supported by this browser, maybe use a pop-up and ask user for zipcode?'); 
    } 
    function success(position) { 
     var latitude = position.coords.latitude; 
     var longitude = position.coords.longitude; 
     this.setState({ 
     location: { 
      latitude: latitude, 
      longitude: longitude 
     } 
     }); 
     this._getWeather(this.state.location.latitude, this.state.location.longitude); 
    } 
    function error(err) { 
     console.warn('ERROR(' + err.code + '): ' + err.message); 
     this.setState({ 
     location: 'ERROR(' + err.code + '): ' + err.message 
     }); 
    } 
    navigator.geolocation.getCurrentPosition(success.bind(this), error.bind(this)); 
    }, 
+0

我也可以間歇性地解決這個問題。 – stueynet

回答

2

我不知道答案,但我注意到這... 我使用HTTP服務器-o在命令提示符在Visual Studio Code中運行它,當它出現在谷歌瀏覽器中時出現此錯誤,但是,如果我將網址'http://127.0.0.1:8082/'複製到剪貼板並關閉了初始Chrome瀏覽器,則從我的桌面上打開一個全新的實例,然後粘貼在它工作正常的網址!

一些事「新鮮」的會話使用我的設置(允許任何網站跟蹤我的位置)正確,因爲我打算而是通過VSC推出的其他方式不...仍在調查......

+0

同樣的問題在這裏,你有沒有取得任何進展?感謝分享 – troig

相關問題