通过经纬度获取中心点,以及绑定的缩放级别
分类:地图(Maps)| 发布:camnprbubuol| 查看: | 发表时间:2011/10/26
-
- function getRoom(diff){
- var room = new Array(0, 1, 2, 3, 4, 5, 6,7,8, 9, 10, 11, 12, 13, 14);
- var diffArr = new Array(360,180,90,45,22,11,5,2.5,1.25,0.6,0.3,0.15,0.07,0.03,0);
- //等级room和diffArr的关系是:360/Math.Pow(2,room)=diffArr
- for(var i = 0; i < diffArr.length; i ++){
- if((diff - diffArr[i]) >= 0){
- return room[i];
- }
- }
- return 14;
- }
-
-
- function getCenterPoint(maxJ,minJ,maxW,minW){
- if(maxJ==minJ&&maxW==minW)return [maxJ,maxW,0];
- var diff = maxJ - minJ;
- if(diff < (maxW - minW))diff = maxW - minW;
- diff = parseInt(10000 * diff)/10000;
- var centerJ = minJ*1000000+1000000*(maxJ - minJ)/2;
- var centerW = minW*1000000+1000000*(maxW - minW)/2;
- var zoom = getRoom(diff);
- return [centerJ/1000000,centerW/1000000,zoom];
- }
来源:http://lovebeyond.iteye.com/blog/900501