先看看效果:

再贴代码:
var map = new BMap.Map("map");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 16);
var geocoder = new BMap.Geocoder();
var locationOptions = {
poiRadius: 300
}
map.addEventListener("click", function(e){
var pt = e.point;
geocoder.getLocation(pt, function(result){
if (result){
var description = result.address;
if (result.surroundingPois[0]){
var poi = result.surroundingPois[0];
description += "," +
poi.title + "向" + getDirDescription(result.point, poi.point) + " " +
Math.round(map.getDistance(result.point, poi.point)) + "米。"
}
alert(description);
}
}, locationOptions)
});
/**
* 获取两点东西南北的位置关系
*/
function getDirDescription(pt1, pt2){
var h = pt1.lng - pt2.lng;
var v = pt1.lat - pt2.lat;
if (Math.abs(h) > Math.abs(v)){
if (h < 0){
return "西";
}
else {
return "东";
}
}
else {
if (v < 0){
return "南";
}
else {
return "北";
}
}
}

再贴代码:
var map = new BMap.Map("map");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 16);
var geocoder = new BMap.Geocoder();
var locationOptions = {
poiRadius: 300
}
map.addEventListener("click", function(e){
var pt = e.point;
geocoder.getLocation(pt, function(result){
if (result){
var description = result.address;
if (result.surroundingPois[0]){
var poi = result.surroundingPois[0];
description += "," +
poi.title + "向" + getDirDescription(result.point, poi.point) + " " +
Math.round(map.getDistance(result.point, poi.point)) + "米。"
}
alert(description);
}
}, locationOptions)
});
/**
* 获取两点东西南北的位置关系
*/
function getDirDescription(pt1, pt2){
var h = pt1.lng - pt2.lng;
var v = pt1.lat - pt2.lat;
if (Math.abs(h) > Math.abs(v)){
if (h < 0){
return "西";
}
else {
return "东";
}
}
else {
if (v < 0){
return "南";
}
else {
return "北";
}
}
}