注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

快乐小屋

 
 
 

日志

 
 

Arcgis Flex显示GoogleMap二维地图,卫星地图  

2013-04-27 17:07:09|  分类: Flex |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

View Code
package GoogleMap {
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.LOD;
import com.esri.ags.layers.supportClasses.TileInfo;

import flash.net.URLRequest;

import mx.collections.ArrayCollection;
import mx.controls.Alert;

/**
* Google切图图层
* yjq
*/
public class GoogleTilesMapServiceLayer extends TiledMapServiceLayer{
function GoogleTilesMapServiceLayer(){
buildTileInfo();
setLoaded(true);
}

/**
* 二维普通地图url
*/
private var _baseUrl:String = "http://mt2.google.cn/vt/v=w2.116&hl=zh-CN&gl=cn&s=";//&x=0&y=1&z=2

/**
* 卫星地图地图要素Url
*/
private var _satelliteFeatureUrl:String = "http://mt3.google.cn/vt/imgtp=png32&lyrs=h@174000000&hl=zh-CN&gl=cn&src=app&s=Galileo";

/**
* 卫星地图的底图
*/
private var _satelliteUrl:String = "http://mt3.google.cn/vt/lyrs=s@106&hl=zh-CN&gl=cn&src=app&s=Ga";

/**
* 设置显示卫星地图上的地图要素
*
*/
public function setDisplaySatelliteFeature():void{
//设置当前显示卫星地图上地图要素
_mapType = 0;
_baseUrl = _satelliteFeatureUrl;
}

/**
* 地图显示方式
* 0:普通二维地图 1:卫星地图
*/
private var _mapType:int = 0;


/**
* 地图显示方式
* 0:普通二维地图 1:卫星地图
*/
public function get mapType():int{
return _mapType;
}

private var _satellitFeatureLayer:GoogleTilesMapServiceLayer = null;

[Bindable]
/**
* 地图显示方式
* 0:普通二维地图 1:卫星地图
*/
public function set mapType(value:int):void{
_mapType = value;
if(_mapType<0||_mapType>1){
_mapType = 0;
}
if(_mapType==1){//如果是卫星地图,则还要显示其上的地理要素
_satellitFeatureLayer = new GoogleTilesMapServiceLayer();
_satellitFeatureLayer.setDisplaySatelliteFeature();
var currentLayerIndx:int = (this.map.layers as ArrayCollection).getItemIndex(this);
this.map.addLayer(_satellitFeatureLayer,currentLayerIndx+1);
}else if(_satellitFeatureLayer!=null){
this.map.removeLayer(_satellitFeatureLayer);
_satellitFeatureLayer = null;
}
this.refresh();
}

private var _tileInfo:TileInfo = new TileInfo();
override public function get tileInfo():TileInfo{
return _tileInfo;
}


override public function get units():String{
return "esriDecimalDegrees";
}

/**
* 分图范围
*/
override public function get fullExtent():Extent{
return new Extent(-22041257.773878, -32673939.6727517, 22041257.773878, 20851350.0432886, new SpatialReference(102113));
}

/**
* 初使范围
*/
override public function get initialExtent():Extent {
return new Extent(-22041257.773878, -32673939.6727517, 22041257.773878, 20851350.0432886, new SpatialReference(102113));
}

/**
*空间参考
*/
override public function get spatialReference():SpatialReference{
return new SpatialReference(102113);//空间参考
}


/**
* 得到切片url
* @param level 显示级别
* @param row 行
* @param col 列
* @return
*
*/
override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest{
var url:String = null;
if(_mapType==0){
url = _baseUrl
}else if(_mapType==1){
url = _satelliteUrl;
}
url = url+"&x="+col+"&y="+row+"&z="+level;
return new URLRequest(url);
}

/**
*初使化切片信息
*/
private function buildTileInfo():void{
_tileInfo.height=256;//切片大小
_tileInfo.width=256;
_tileInfo.origin=new MapPoint(-20037508.342787, 20037508.342787);//坐标每户的开始坐标,参照WGS_1984
_tileInfo.spatialReference=new SpatialReference(102113);

_tileInfo.lods = [ //比例尺 :比例级别,切片分辨雍,比例尺
new LOD(0, 156543.03392800014, 591657527.591555),
new LOD(1, 78271.516963999937, 295828763.79577702),
new LOD(2, 39135.758482000092, 147914381.89788899),
new LOD(3, 19567.879240999919, 73957190.948944002),
new LOD(4, 9783.9396204999593, 36978595.474472001),
new LOD(5, 4891.9698102499797, 18489297.737236001),
new LOD(6, 2445.9849051249898, 9244648.8686180003),
new LOD(7, 1222.9924525624949, 4622324.4343090001),
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.7773142679493699, 18055.954822),
new LOD(16, 2.3886571339746849, 9027.9774109999998),
new LOD(17, 1.1943285668550503, 4513.9887049999998),
new LOD(18, 0.59716428355981721, 2256.994353),
new LOD(19, 0.29858214164761665, 1128.4971760000001)
];

}
}
}

测试页面

View Code
<?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" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags" xmlns:GoogleMap="GoogleMap.*">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:VGroup left="10" top="10" bottom="10" right="10">
<s:ComboBox id="mapType_cmb" labelField="name" >
<s:ArrayCollection>
<fx:Array>
<fx:Object name="普通二维地图" />
<fx:Object name="卫星地图" />
</fx:Array>
</s:ArrayCollection>
</s:ComboBox>
<esri:Map width="100%" height="100%" >
<GoogleMap:GoogleTilesMapServiceLayer mapType="{mapType_cmb.selectedIndex}" />
</esri:Map>
</s:VGroup>
</s:Application>


  评论这张
 
阅读(525)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018