ios 百度地图指定区域_获取百度地图可视区域范围的数据
有個業(yè)務(wù)場景,需要根據(jù)獲取到的地圖區(qū)域顯示,根據(jù)相應(yīng)的經(jīng)緯度反查 左側(cè)區(qū)域的會議室。
思路:
1.得到百度地圖可視區(qū)域--可視區(qū)域的中心點
2.可視區(qū)域的四個角的其中兩個(東北角+西南角)
http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a1b2
getSouthWest()Point返回矩形區(qū)域的西南角
getNorthEast()Point返回矩形區(qū)域的東北角
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);
}
);
這樣就能獲取視圖范圍內(nèi)的經(jīng)緯度范圍數(shù)據(jù).
總結(jié)
以上是生活随笔為你收集整理的ios 百度地图指定区域_获取百度地图可视区域范围的数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “荒涂趣山楹”下一句是什么
- 下一篇: 地下城与勇士巨龙地下城进图后进度条有什么