h5地理位置定位

//step1:判断浏览器是否支持
if (navigator.geolocation){
//step 2:调用 getCurrentPosition() 函数获取用户当前位置。
navigator.geolocation.getCurrentPosition(
function(ev){//step3:用经纬度描述具体位置
document.getElementById('geo').innerHTML = '纬度:'+ev.coords.latitude+' 经度:'+ev.coords.longitude;
},
function(err){
document.getElementById('geo').innerHTML = err.code+':'+err.message;
})
}else{
alert('该浏览器不支持');
原文地址:https://www.cnblogs.com/fwjlucifinil/p/13446577.html