<!DOCTYPE html>
<html>
<head>
    <title>手机精准定位</title>
    <script src='http://api.map.baidu.com/api?v=2.0&ak=fUmCszw7O7G8rBv2MO4MLLNIA5DNWLoj'></script>
    <script type='text/javascript'>
        var geolocation = new BMap.Geolocation();
        geolocation.getCurrentPosition(function(r){
            if(this.getStatus() == BMAP_STATUS_SUCCESS){
                var address = r.address;
                document.getElementById('address').value = address;
            }else {
                alert('failed'+this.getStatus());
            }        
        },{enableHighAccuracy: true})
    </script>
</head>
<body>
    <input type='text' id='address' placeholder='获取当前位置'>
</body>
</html>
手机网页精准定位代码:HTML+百度地图API实现

原文地址: https://www.cveoy.top/t/topic/oYZX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录