I just found that getCurrentPosition() is deprecated from Google Chrome for insecure origins, they are just allowing HTTPS. But I'm trying to run this html file on my machine which to my knowledge is supposed to be secure.
Example from w3school
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
but that doesn't show my current location, if that means that chrome see my local machine as an insecure origin, Is there any way to change that?