2017-07-02 41 views
3

我得到一個400錯誤,只要我使用Visual Studio Code,但是當我使用Brackets它工作正常。錯誤:網絡位置提供商在'https://www.googleapis.com/':返回的錯誤代碼400

什麼是導致此錯誤,我該如何解決它?

預先感謝您:)

<script> 
    var watcher; 
    var geoLocator; 
    window.onload = function() { 
     geoLocator = window.navigator.geolocation; 
     var posOptions = { 
      enableHighAccuracy: true, 
      timeout: 45000 
     }; 
     watcher = geoLocator.watchPosition(successPosition, errorPosition, posOptions); 
    } 

    function successPosition(pos) { 
     var sp = document.createElement("p"); 
     sp.innerText = "Latitude: " + pos.coords.latitude + " Longitude: " + pos.coords.longitude; 
     document.getElementById("geoResults").appendChild(sp); 
     geoLocator.clearWatch(watcher); 
    } 

    function errorPosition(err) { 
     var sp = document.createElement("p"); 
     sp.innerText = "error: " + err.message; + " code:" + err.code; 
     document.getElementById("geoResults").appendChild(sp); 

    } 
</script> 

回答

0

我有同樣的問題。清除瀏覽器保存的所有緩存和Cookie並重試。這對我來說很有用。清除後,打開瀏覽器的新實例以保證安全。