地图切片 博客分类: GIS 没有标签
程序员文章站
2024-03-14 08:34:52
...
这个是搜狗 var tilePos:Point = new Point(col,row); zoom = zoom - 1; var offsetX:Number = Math.pow(2,zoom); var offsetY:Number = offsetX - 1; var numX:Number = tilePos.x - offsetX; var numY:Number = (-tilePos.y) + offsetY; zoom = zoom + 1; var l:int = 729 - zoom; if (l == 710) l = 792; var blo:Number = Math.floor(numX / 200); var bla:Number = Math.floor(numY / 200); var los:String,las:String,blos:String,blas:String; if (numX < 0) los = "M" + ( - numX); else los = "" + numX; if (numY < 0) las = "M" + ( - numY); else las = "" + numY; if (blo < 0) blos = "M" + ( - blo); else blos = "" + blo; if (bla < 0) blas = "M" + ( - bla); else blas = "" + bla; var x:String = numX.toString().replace("-","M"); var y:String = numY.toString().replace("-","M"); var num:int = (tilePos.x + tilePos.y) % tileUrls.length; var strURL:String = ""; strURL = tileUrls[num] + l + "/" + blos + "/" + blas + "/" + x + "_" + y + ".GIF";
这个是51地图
//覆盖加载地图数据的方法,这个很重要,地图数据从这里读取 override public function loadTile(tilePos:Point, zoom:Number):DisplayObject { var testLoader:Loader = new Loader(); var strURL:String = ""; //51地图是从左下角开始为0,0的,所以这里的Y需要翻转一下 tilePos.y = Math.pow(2,zoom - 1) - (tilePos.y - 1); strURL = getTileUrl(tilePos,zoom); //trace("x:" + tilePos.x + ",y:" + tilePos.y + ",url:" + strURL); var urlRequest:URLRequest; urlRequest = new URLRequest(strURL); //没有地图时显示的内容 testLoader.load(urlRequest); testLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); return testLoader; }