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

Viewed 1107

I get a 400 error whenever I'm using Visual Studio Code, but when I'm using Brackets it's working fine.

What is causing this error and how can I fix it?

Thank you in advance :)

 <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 Answers
Related