H5獲取定位信息

<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=aAP7FmnDEeZAX7Cvdbe7kdKE

"></script>

<title>百度地圖的定位</title>
</head>
<body>
<script type="text/javascript">
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(r){
        if(this.getStatus() == BMAP_STATUS_SUCCESS){
            alert('您的位置:'+r.point.lng+','+r.point.lat);
        }else {
            alert('failed'+this.getStatus());
        }
    },{enableHighAccuracy: true})
</script>


</body>

要用到百度API,就這麼簡單出來啦~javascript

相關文章
相關標籤/搜索