标签:cal scom ber blank osi asc this tree city
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>测试定位</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4&ak=ia6HfFL660Bvh43exmH9LrI6"></script>
</head>
<body>
<script type="text/javascript" >
var geolocation = new BMap.Geolocation();
// 创建地理编码实例
var myGeo = new BMap.Geocoder();
geolocation.getCurrentPosition(function(r){
if(this.getStatus() == BMAP_STATUS_SUCCESS){
var pt = r.point;
// 根据坐标得到地址描述
myGeo.getLocation(pt, function(result){
if (result){
var addComp = result.addressComponents;
alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
}
});
}
});
</script>
</body></html>
标签:cal scom ber blank osi asc this tree city
原文地址:https://www.cnblogs.com/xieyongbin/p/9685944.html