0
私はhtml5 geolocation apiについて学習しています。この簡単なコードを実践のために書いています。しかし、私は "位置情報が利用できません"を取得し続け、私は理由を知りません。私はこれにかなり新しいですし、いくつかの助けに感謝します。html5 geolocationを取得できません
ここに私のコードです。 var userLocation = document.querySelector(".location");
document.getElementById("btn").addEventListener("click", function(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition, showError);
userLocation.textContent = "Checking Location...";
}
else {
userLocation.textContent = "Unable to retrieve location..";
}
});
function showPosition(position){
userLocation.textContent = position.coords.longitude;
}
function showError(error){
switch(error.code){
case error.PERMISSION_DENIED:
alert("User denied the request for Geolocation.");
break;
case error.POSITION_UNAVAILABLE:
alert("Location information is unavailable.");
break;
case error.TIMEOUT:
alert("The request to get user location timed out.");
break;
case error.UNKNOWN_ERROR:
alert("An unknown error occurred.");
break;
}
}
返答いただき、ありがとうございました。私のPCIカードでは、Linuxのubuntuで動作できないという問題がありました。しかし、助けてくれてありがとう。 –