I tested the following code, taken from w3schools:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>TEST GPS</title>
</head>
<body>
<h1>Testing the GPS</h1>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
</body>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
function showError(error) {
switch(error.code) {
case error.PERMISSION_DENIED:
x.innerHTML = "User denied the request for Geolocation."
break;
case error.POSITION_UNAVAILABLE:
x.innerHTML = "Location information is unavailable."
break;
case error.TIMEOUT:
x.innerHTML = "The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
x.innerHTML = "An unknown error occurred."
break;
}
}
</script>
</html>
And… it works! If I click on the button and give the permission, my GPS coordinates are displayed.
So, what’s wrong on open street map?
I found a way to get some logs on this page: I used EMBED_CONSOLE=1 sailfish-browser
.
This is what I get on openstreetmap.org:
ContentPermissionPrompt.js on message received: top:embedui:permissions, msg:{
"allow": true,
"checkedDontAsk": false,
"id": "www.openstreetmap.org geolocation"
}
JavaScript error: https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js, line 7: Error: Invalid LatLng object: (NaN, NaN)
CONSOLE: {"logLevel":3,"timeStamp":1604513555218,"message":"[JavaScript Error: \"Error: Invalid LatLng object: (NaN, NaN)\" {file: \"https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js\" line: 7}]\nS@https://www.openstr
eetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:11950\nk@https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:12173\nT.prototype.extend@https://www.openstreetmap.org/
assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:30062\nT@https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:11835\nC@https://www.openstreetmap.org/assets/application-f9e3c9c78
8a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:11893\nS.prototype.toBounds@https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:8:258\nHn<._handleGeolocationResponse@https://www.openstreetmap.org/assets/app
lication-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:8:13700\n","debug":0,"info":1,"warn":2,"error":3}
JavaScript error: https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js, line 7: Error: Invalid LatLng object: (NaN, NaN)
CONSOLE: {"logLevel":3,"timeStamp":1604513556145,"message":"[JavaScript Error: \"Error: Invalid LatLng object: (NaN, NaN)\" {file: \"https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js\" line: 7}]\nS@https://www.openstr
eetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:11950\nk@https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:12173\nT.prototype.extend@https://www.openstreetmap.org/
assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:30062\nT@https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:11835\nC@https://www.openstreetmap.org/assets/application-f9e3c9c78
8a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:7:11893\nS.prototype.toBounds@https://www.openstreetmap.org/assets/application-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:8:258\nHn<._handleGeolocationResponse@https://www.openstreetmap.org/assets/app
lication-f9e3c9c788a9c5fc4e78fc331240f47a594532c9a12aa671d2509f9062fabbc6.js:8:13700\n","debug":0,"info":1,"warn":2,"error":3}
[...]
The first part of the log is the permission prompt. Then, the error message is looping indefinitively. It seems that the coordinates are not parsed correctly.
Wrong format? Empty data? I don’t know yet. If someone has a clue or another test to propose, I am listening.