Html5获取地理位置
我这个是放在微信浏览器下,找附件门店的。安卓 ios都支持
if (navigator.geolocation) {
    
    navigator.geolocation.getCurrentPosition(function(pos) {
    // A callback function that takes a Position object as its sole input parameter.
    // 成功回调函数,接受一个地理位置的对象作为参数。
    // https://developer.mozilla.org/en-US/docs/Web/API/Position 参数说明
    alert(pos.coords.latitude + ' '+pos.coords.longitude);
    }, function(err) {
    // An optional callback function that takes a PositionError object as its sole input parameter.
    // 错误的回调
    // https://developer.mozilla.org/en-US/docs/Web/API/PositionError 错误参数
}, {
    enableHighAccuracy: true, // 是否获取高精度结果
    timeout: 5000, //超时,毫秒
    maximumAge: 0 //可以接受多少毫秒的缓存位置
    // 详细说明 https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions
    });
} else {
    alert('抱歉!您的浏览器无法使用地位功能');
}