• ArcGIS Server flex加载google地图


      ArcGIS Server flex加载google地图,早已不是什么技术问题。只不过今天结合着项目,底图和项目数据的坐标系统始终没有匹配。即使匹配了,也达不到精度问题。最后,且算是为客户多奉献了一些,将他们的数据重新转换为Web Mector系统,以和Google底图相匹配。囧~~他们的数据量不是有点大,那是相当的大~~

       言归正传,ArcGIS Server加载google地图,只需要重写TiledMapServiceLayer类即可。关键代码如下:

    Flex代码 复制代码 收藏代码
    1. package util   
    2. {   
    3.     import com.esri.ags.SpatialReference;   
    4.     import com.esri.ags.geometry.Extent;   
    5.     import com.esri.ags.geometry.MapPoint;   
    6.     import com.esri.ags.layers.TiledMapServiceLayer;   
    7.     import com.esri.ags.layers.supportClasses.*;   
    8.     import flash.net.URLRequest;     
    9.        
    10.         //扩展TiledMapServiceLayer图层实现加载google地图     
    11.     public class GoogleMapLayer extends TiledMapServiceLayer     
    12.     {     
    13.         private var _tileInfo:TileInfo=new TileInfo();     
    14.         private var _baseURL:String="";     
    15.         public function GoogleMapLayer()   
    16.         {    
    17.             super();   
    18.             buildTileInfo();    
    19.             setLoaded(true);    
    20.         }    
    21.         override public function get fullExtent():Extent   
    22.         {    
    23.        return new Extent(-20037508.342787, -20037508.34278720037508.34278720037508.342787, new SpatialReference(102113));    
    24.                     }    
    25.         override public function get initialExtent():Extent   
    26.         {    
    27.     return new Extent(-20037508.342787, -20037508.34278720037508.34278720037508.342787, new SpatialReference(102113));      
    28.         }   
    29.         override public function get spatialReference():SpatialReference    
    30.         {    
    31.             return new SpatialReference(102113);    
    32.         }    
    33.         override public function get tileInfo():com.esri.ags.layers.supportClasses.TileInfo    
    34.         {    
    35.             return _tileInfo;    
    36.         }     
    37.         //获取URL     
    38.         override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest     
    39.         {    
    40.     var url:String="http://mt0.google.cn/vt/v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" +     
    41.                 "y=" + row + "&" + "z=" + level+ "&s=";     
    42.         return new URLRequest(url);    
    43.         }    
    44.         private function buildTileInfo():void    
    45.         {    
    46.                         _tileInfo.height=256;    
    47.             _tileInfo.width=256;    
    48.             _tileInfo.origin=new MapPoint(-20037508.34278720037508.342787);   
    49.             _tileInfo.spatialReference=new SpatialReference(102113);     
    50.             _tileInfo.lods = [new LOD(0156543.033928591657527.591555),     
    51.                 new LOD(1,78271.5169639999295828763.795777), new LOD(239135.7584820001147914381.897889),     
    52.                 new LOD(3,19567.879240999973957190.948944),  new LOD(49783.9396204999636978595.474472),     
    53.                 new LOD(5,4891.9698102499818489297.737236),  new LOD(62445.984905124999244648.868618),     
    54.                 new LOD(7,1222.992452562494622324.434309),  new LOD(8611.496226281382311162.217155),     
    55.                 new LOD(9,305.7481131405581155581.108577),  new LOD(10152.874056570411577790.554289),     
    56.                 new LOD(11,76.4370282850732288895.277144),  new LOD(1238.2185141425366144447.638572),     
    57.                 new LOD(13,19.109257071268372223.819286),  new LOD(149.5546285356341536111.909643),     
    58.                 new LOD(15,4.7773142679493718055.954822),  new LOD(162.388657133974689027.977411),     
    59.                 new LOD(171.194328566855054513.988705),  new LOD(180.5971642835598172256.994353),     
    60.                 new LOD(190.2985821416476171128.497176)];    
    61.                     
    62.         }     
    63.     }     
    64. }  
    package util
    {
    	import com.esri.ags.SpatialReference;
    	import com.esri.ags.geometry.Extent;
    	import com.esri.ags.geometry.MapPoint;
    	import com.esri.ags.layers.TiledMapServiceLayer;
    	import com.esri.ags.layers.supportClasses.*;
    	import flash.net.URLRequest;  
    	
    		//扩展TiledMapServiceLayer图层实现加载google地图  
    	public class GoogleMapLayer extends TiledMapServiceLayer  
    	{  
    		private var _tileInfo:TileInfo=new TileInfo();  
    		private var _baseURL:String="";  
    		public function GoogleMapLayer()
    		{ 
    			super();
    			buildTileInfo(); 
    			setLoaded(true); 
    		} 
    		override public function get fullExtent():Extent
    		{ 
           return new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, new SpatialReference(102113)); 
    					} 
    		override public function get initialExtent():Extent
    		{ 
    	return new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, new SpatialReference(102113));   
    		}
    		override public function get spatialReference():SpatialReference 
    		{ 
    			return new SpatialReference(102113); 
    		} 
    		override public function get tileInfo():com.esri.ags.layers.supportClasses.TileInfo 
    		{ 
    			return _tileInfo; 
    		}  
    		//获取URL  
    		override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest  
    		{ 
    	var url:String="http://mt0.google.cn/vt/v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" +  
    				"y=" + row + "&" + "z=" + level+ "&s=";  
    		return new URLRequest(url); 
    		} 
    		private function buildTileInfo():void 
    		{ 
    						_tileInfo.height=256; 
    			_tileInfo.width=256; 
    			_tileInfo.origin=new MapPoint(-20037508.342787, 20037508.342787);
    			_tileInfo.spatialReference=new SpatialReference(102113);  
    			_tileInfo.lods = [new LOD(0, 156543.033928, 591657527.591555),  
    				new LOD(1,78271.5169639999, 295828763.795777), new LOD(2, 39135.7584820001, 147914381.897889),  
    				new LOD(3,19567.8792409999, 73957190.948944),  new LOD(4, 9783.93962049996, 36978595.474472),  
    				new LOD(5,4891.96981024998, 18489297.737236),  new LOD(6, 2445.98490512499, 9244648.868618),  
    				new LOD(7,1222.99245256249, 4622324.434309),  new LOD(8, 611.49622628138, 2311162.217155),  
    				new LOD(9,305.748113140558, 1155581.108577),  new LOD(10, 152.874056570411, 577790.554289),  
    				new LOD(11,76.4370282850732, 288895.277144),  new LOD(12, 38.2185141425366, 144447.638572),  
    				new LOD(13,19.1092570712683, 72223.819286),  new LOD(14, 9.55462853563415, 36111.909643),  
    				new LOD(15,4.77731426794937, 18055.954822),  new LOD(16, 2.38865713397468, 9027.977411),  
    				new LOD(17, 1.19432856685505, 4513.988705),  new LOD(18, 0.597164283559817, 2256.994353),  
    				new LOD(19, 0.298582141647617, 1128.497176)]; 
    				 
    		}  
    	}  
    }
    



    好了,就可以看到效果啦[img][/img]

    转载:http://hi-ajg.iteye.com/blog/1149819
      

  • 相关阅读:
    JAVA EE获取浏览器和操作系统信息
    ANT与SVN集成
    ANT property三种使用方式
    跨机器的文件夹访问和传输方法
    yolov5网络结构分析
    点到直线距离计算及g++编译
    深拷贝与浅拷贝(c++和python)
    qt工程环境设置
    Git 篇
    PyCharm 使用的技巧
  • 原文地址:https://www.cnblogs.com/x38160/p/3172989.html
Copyright © 2020-2023  润新知