ArcGIS for Flex中引入google map作底图
上篇文章到在ArcGIS View中引入google map,这里讲ArcGIS for Flex中引入google map作底图。
同样道理,以google map作底图,需要编写继承自TiledMapServiceLayer的帮助类MapOperate。
MapOperate类的代码如下:
package
{ 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; public class MapOperate extends TiledMapServiceLayer
{
private var _tileInfo:TileInfo=new TileInfo();
private var _baseURL:String="";
private var MapStyle:String=""; public function MapOperate(vMapStyle:String)
{
this.MapStyle=vMapStyle;
super();
buildTileInfo();
setLoaded(true); } override public function get fullExtent():Extent
{
return new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, new SpatialReference());
} override public function get initialExtent():Extent
{
return new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, new SpatialReference());
} override public function get spatialReference():SpatialReference
{
return new SpatialReference();
} override public function get tileInfo():com.esri.ags.layers.supportClasses.TileInfo
{
return _tileInfo;
} //获取矢量地图
override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest
{
var s:String = "Galileo".substring(, (( * col + row) % )); var url:String ="";
if (this.MapStyle == "Vector")
{
url = "http://mt" + (col % ) + ".google.com/vt/lyrs=m@158000000&hl=zh-CN&gl=cn&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level + "&" +
"s=" + s;
} //获取地形图
else if (this.MapStyle == "Terrain")
{
url = "http://mt" + (col % ) + ".google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&" +
//url = "http://mt"+(col%4)+".google.com/vt/lyrs=t@128,r@177000000&hl=zh-CN&gl=cn&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level + "&" +
"s=" + s;
} //获取影像地图
else if (this.MapStyle == "Image")
{
url = "http://mt" + (col % ) + ".google.com/vt/lyrs=s&hl=en&gl=en&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level + "&" +
"s=" + s;
} //获取道路等POI,和影像地图配合使用
else if (this.MapStyle == "POI")
{
url = "http://mt" + (col % ) + ".google.com/vt/imgtp=png32&lyrs=h@169000000&hl=zh-CN&gl=cn&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level + "&" +
"s=" + s;
}
return new URLRequest(url);
}
public function set url(vals:String):void
{
this._baseURL = vals;
}
private function buildTileInfo():void
{
_tileInfo.height=;
_tileInfo.width=;
_tileInfo.origin=new MapPoint(-20037508.342787, 20037508.342787);
_tileInfo.spatialReference=new SpatialReference();
_tileInfo.lods = [
new LOD(, 156543.033928, 591657527.591555),
new LOD(, 78271.5169639999, 295828763.795777),
new LOD(, 39135.7584820001, 147914381.897889),
new LOD(, 19567.8792409999, 73957190.948944),
new LOD(, 9783.93962049996, 36978595.474472),
new LOD(, 4891.96981024998, 18489297.737236),
new LOD(, 2445.98490512499, 9244648.868618),
new LOD(, 1222.99245256249, 4622324.434309),
new LOD(, 611.49622628138, 2311162.217155),
new LOD(, 305.748113140558, 1155581.108577),
new LOD(, 152.874056570411, 577790.554289),
new LOD(, 76.4370282850732, 288895.277144),
new LOD(, 38.2185141425366, 144447.638572),
new LOD(, 19.1092570712683, 72223.819286),
new LOD(, 9.55462853563415, 36111.909643),
new LOD(, 4.77731426794937, 18055.954822),
new LOD(, 2.38865713397468, 9027.977411),
new LOD(, 1.19432856685505, 4513.988705),
new LOD(, 0.597164283559817, 2256.994353),
new LOD(, 0.298582141647617, 1128.497176)
];
} public function lon2Mercator(px:int):int
{
var x:int = px * 20037508.34 / ;
return x;
} public function lat2Mercator(py:int):int
{
var y:int;
y = Math.log(Math.tan(( + py) * Math.PI / )) / (Math.PI / );
y = y * 20037508.34 / ;
return y;
}
}
}
下面是引入代码:
//加载Google图层
var googleLayer:MapOperate = new MapOperate("Image");
myMap.addLayer(googleLayer);
运行效果:


ArcGIS for Flex中引入google map作底图的更多相关文章
- ArcGIS Viewer for Flex中引入google map作底图
在ArcGIS Viewer for Flex开发中,经常需要用到google map作为底图,我们不能通过ArcGIS Viewer for Flex - Application Builder轻易 ...
- ArcGIS Viewer for Flex中引入google map作底图 (转)
在ArcGIS Viewer for Flex开发中,经常需要用到google map作为底图,我们不能通过ArcGIS Viewer for Flex - Application Builder轻易 ...
- arcgis api for silverlight使用google map等多个在线地图
原文 http://blog.csdn.net/leesmn/article/details/6820245 无可否认,google map实在是很漂亮.可惜对于使用arcgis api for si ...
- Flex加载google地图、百度地图以及天地图作底图
一 Flex加载Google地图作底图 (1)帮助类GoogleLayer.as /* * 根据输入的地图类型加载Google地图(by chenyuming) */ package Layers ...
- Google map API V3
本文主要总结Google map API V3使用中最简单也是最常见的一些操作以及相关概念,如果需要更加详细的信息,请直接阅读Google提供的关于map的文档. google map api v3文 ...
- Android Google Map API使用的八个步骤
本系列教程将分为两部分,第一部分是指导用户使用Mapview控件进行编程,其中包括了如何获得Google Map API,如何使用该API进行简单的开发,如何获得用户当前所在的位置.第二部分则包括如何 ...
- [小技巧] google map使用
在网页中打开 google map 中,可以使用 shift + - 来缩小地图,shift + + 来放大地图.
- Flexviewer使用Google地图作为底图
Flexviewer使用Google地图作为底图: 在使用google地图作底图前提是你需要在Flex中实现加载google地图的代码(网上一大堆,随便找), 在只加载google地图的情况下,成功显 ...
- Android中Google地图路径导航,使用mapfragment地图上画出线路(google map api v2)详解
在这篇里我们只聊怎么在android中google map api v2地图上画出路径导航,用mapfragment而不是mapview,至于怎么去申请key,manifest.xml中加入的权限,系 ...
随机推荐
- 更换内核后重编virtualbox内核模块
这些天编译了一个4.1.15内核,因此vb原来的模块就不能用了,因此要重新编译(当然,reinstall也可以,觉得大动干戈,不符合个人做事风格) 如果不重编运行会有如下错误提示: # virtual ...
- HDU 2089 不要62
也是简单的数位dp. #include<iostream> #include<cstdio> #include<cstring> #include<algor ...
- UE4 异步资源加载
http://blog.csdn.net/pizi0475/article/details/48178861 http://blog.sina.com.cn/s/blog_710ea1400102vl ...
- ireport开发报表,Java和JSP端如何集成
Java端: @RequestMapping("/report") public String report() { return "/credit/report/rep ...
- JavaScript中this和$(this)之间的区别以及extend的使用
jQuery中this和$(this)之间的区别: this返回的是当前对象的html对象,而$(this)返回的是当前对象的jQuery对象 举个正确的Demo实例: $("#textbo ...
- A - Humble Numbers
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Pract ...
- Eclipse上运行第一个Hadoop实例 - WordCount(单词统计程序)
需求 计算出文件中每个单词的频数.要求输出结果按照单词的字母顺序进行排序.每个单词和其频数占一行,单词和频数之间有间隔. 比如,输入两个文件,其一内容如下: hello world hello had ...
- (实用篇)PHP递归实现无限级分类
在一些复杂的系统中,要求对信息栏目进行无限级的分类,以增强系统的灵活性.那么PHP是如何实现无限级分类的呢?我们在本文中使用递归算法并结合mysql数据表实现无限级分类. 在一些复杂的系统中,要求对信 ...
- Socket编程基础——面向连接TCP
WinSock是Windows环境下的网络编程接口,它最初是基于Unix环境下的BSD Socket,是一个与网络协议无关的编程接口.WinSock包含两个主要版本,即WinSock1和WinSock ...
- POJ 1511 Invitation Cards (spfa的邻接表)
Invitation Cards Time Limit : 16000/8000ms (Java/Other) Memory Limit : 524288/262144K (Java/Other) ...