ios 百度地图指定区域_获取百度地图可视区域范围的数据
有個業務場景,需要根據獲取到的地圖區域顯示,根據相應的經緯度反查 左側區域的會議室。
思路:
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);
}
);
這樣就能獲取視圖范圍內的經緯度范圍數據.
總結
以上是生活随笔為你收集整理的ios 百度地图指定区域_获取百度地图可视区域范围的数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “荒涂趣山楹”下一句是什么
- 下一篇: 地下城与勇士巨龙地下城进图后进度条有什么