有個業務場景,需要根據獲取到的地圖區域顯示,根據相應的經緯度反查 左側區域的會議室。
思路:
1.得到百度地圖可視區域--可視區域的中心點
2.可視區域的四個角的其中兩個(東北角+西南角)

http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a1b2
getSouthWest()Point返回矩形區域的西南角
getNorthEast()Point返回矩形區域的東北角
getCenter()Point返回矩形的中心點
在 map初始化 自定義的方法 setMapEvent() 集中聲明:
map.addEventListener(
'zoomend',function(evt){
console.log("#zoomend##"+this.getCenter().lng + '---'+this.getCenter().lat);
var bound = this.getBounds();
console.log("@@@@@@@@@@getSouthWest %"+bound.getSouthWest().lng + " lat: "+bound.getSouthWest().lat);
console.log("@@@@@@@@@@NorthEast %"+bound.getNorthEast().lng + " lat: " + bound.getNorthEast().lat);
console.log(this.getCenter().lng + '---'+this.getCenter().lat);
}
);
map.addEventListener(
'moveend',function(evt){
console.log("#zoomend##"+this.getCenter().lng + '---'+this.getCenter().lat);
var bound = this.getBounds();
//console.log("$$$$$moveend @@@@@"+bound.getCenter());
console.log("@@@@@@@@@@moveend getSouthWest %"+bound.getSouthWest().lng + " lat: "+bound.getSouthWest().lat);
console.log("@@@@@@@@@moveend @NorthEast %"+bound.getNorthEast().lng + " lat: " + bound.getNorthEast().lat);
console.log(this.getCenter().lng + '---'+this.getCenter().lat);
}
);

這樣就能獲取視圖范圍內的經緯度范圍數據.