ios 百度地图指定区域_获取百度地图可视区域范围的数据
有個(gè)業(yè)務(wù)場(chǎng)景,需要根據(jù)獲取到的地圖區(qū)域顯示,根據(jù)相應(yīng)的經(jīng)緯度反查 左側(cè)區(qū)域的會(huì)議室。
思路:
1.得到百度地圖可視區(qū)域--可視區(qū)域的中心點(diǎn)
2.可視區(qū)域的四個(gè)角的其中兩個(gè)(東北角+西南角)
http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a1b2
getSouthWest()Point返回矩形區(qū)域的西南角
getNorthEast()Point返回矩形區(qū)域的東北角
getCenter()Point返回矩形的中心點(diǎn)
在 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 百度地图指定区域_获取百度地图可视区域范围的数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: “荒涂趣山楹”下一句是什么
- 下一篇: stm32 内部sram大小_在SRAM