[英]my geolocation(javascript) does not work and I don't know why
I am eventually trying reverse geolocation, however before doing that I want to make sure my geolocation works fine but no luck with my code. 我最终尝试进行反向地理位置定位,但是在此之前,我想确保地理位置定位正常,但我的代码没有运气。
what I am doing is that when user clicks button, my javascript shows latitude and longitude numbers if user agrees with it. 我正在做的是,当用户单击按钮时,如果用户同意,我的javascript将显示纬度和经度数字。
$(".button").click(function(){
var elMap =document.getElementById("showWhere");
var msg ='Sorry, we were unable to get your location';
if(Modernizr.geolocation){
navigator.geolocation.getCurrentLocation(success, fail);
elMap.textContent = 'Checking location...';
} else {
elMap.textContent = msg;
}
function success(position){
msg = '<h3>Lng: <br>';
msg += position.coords.longtitude + '</h3>';
msg +='<h3>lat: <br>';
msg+=position.coords.latitude + '</h3>';
elMap.innerHTML = msg;
}
function fail(msg){
elMap.textContent = msg;
console.log(msg.code);
}
});
I thought it is my click function problem and remove this part but it still does not work. 我以为这是我的点击功能问题,请删除此部分,但仍然无法正常工作。 What did I miss?
我错过了什么? Thank you for in advance :D
预先感谢您:D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.