`
Virgo_S
  • 浏览: 1138736 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ArcGIS Flex API读取Google地图

    博客分类:
  • Flex
阅读更多
效果如下:




GoogleMapLayer.as
package com.esri.arcgis.flex.sample
{
	import com.esri.ags.SpatialReference;
	import com.esri.ags.geometry.Extent;
	import com.esri.ags.geometry.MapPoint;
	import com.esri.ags.layers.supportClasses.LOD;
	import com.esri.ags.layers.supportClasses.TileInfo;
	import com.esri.ags.layers.TiledMapServiceLayer;	
	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():TileInfo
		{
			return _tileInfo;
		}
		
		//获取矢量地图
		override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest
		{
			var url:String="http://mt"+(col%4)+".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)
			];
		}
	}
	
}

ArcGISGoogleMap.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:google="com.esri.arcgis.flex.sample.*" 
			   xmlns:esri="http://www.esri.com/2008/ags">
	<esri:Map>
		<google:GoogleMapLayer id="googleMap" />
	</esri:Map>
</s:Application>

  • 大小: 121.9 KB
分享到:
评论
4 楼 hotdoghotmail 2011-11-15  
非常好很有用
3 楼 yueyou216 2011-09-01  
没报任何错误~你能不能详细的跟我说说你是怎么做的?
你是自己发布了自己的地图?用的本地服务的URL?有点白痴,没明白你这个代码的细致点
2 楼 Virgo_S 2011-08-31  
yueyou216 写道
您好,我这个程序试了好久,都没有地图显示~你能不能把你的源码发给我看下。yueyou216@163.com
谢谢你了~

真是抱歉,我现在已经没有arcgis的环境了,如果报错,你可以把错误贴出来,大家一起研究一下
1 楼 yueyou216 2011-08-29  
您好,我这个程序试了好久,都没有地图显示~你能不能把你的源码发给我看下。yueyou216@163.com
谢谢你了~

相关推荐

Global site tag (gtag.js) - Google Analytics