h5的地理定位
什么是地理定位?
什么是gelocation?
gelocation用于获得用户的地理位置
如何使用?
if(navigator.gelocation){
navigator.gelocation.geCurrentPosition((res)=>{
// 请求成功的回调函数
经度: langitude res.coords.langitude
纬度:latitude res.coords.latitude
},function(err){
console.log("失败的回调函数")
})
}
第三个参数是一个对象,可选,这个对象可以调整数据的收集方式
{
enableHighAccuracy:true|false, 是否开启高精度模式,默认为false
timeout:ms 超时时间,毫秒数
maxmunAge: 这是只表示浏览器重新计算位置的时间间隔,以ms为单位,默认为0
}