1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| //成功时 function onSuccess(position) { var longitude = position.coords.longitude; var latitude = position.coords.latitude; var map = new BMap.Map("allmap"); var point = new BMap.Point(longitude, latitude); var gc = new BMap.Geocoder(); gc.getLocation(point, function(rs) { var addComp = rs.addressComponents; document.getElementById("aera").innerHTML = addComp.province + ", " + addComp.city + ", "+ addComp.district + ", " + addComp.street + ", "+ addComp.streetNumber; }); // 这里后面可以写你的后续操作了 // postData(longitude, latitude); }
|