ArcGIS Viewer for Flex中引入google map作底图 (转)

在ArcGIS Viewer for Flex开发中,经常需要用到google map作为底图,我们不能通过ArcGIS Viewer for Flex - Application Builder轻易的引入google map 作为底图,需要通过程序重写TiledMapServiceLayer来扩展从而加载google map。

这里有写好的GoogleMapLayer.as文件:

package com.esri.viewer
{
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; //扩展TiledMapServiceLayer图层实现加载google地图
public class GoogleMapLayer extends TiledMapServiceLayer
{
private var _tileInfo:TileInfo=new TileInfo();
private var _baseURL:String="";
public var mapStyle: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 s:String = "Galileo".substring(0, ((3 * x + y) % 8));
var url:String; //获取矢量地图
if(mapStyle == "Vector")
{
url = "http://mt"+(col%4)+".google.com/vt/lyrs=m@158000000&hl=zh-CN&gl=cn&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level+ "&" +
"s=" + s;
} //获取地形图
else if(mapStyle == "Terrain")
{
url = "http://mt"+(col%4)+".google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level+ "&" +
"s=" + s;
} //获取影像地图
else if(mapStyle == "Image")
{
url = "http://mt"+(col%4)+".google.com/vt/lyrs=s&hl=en&gl=en&" +
"x=" + col + "&" +
"y=" + row + "&" +
"z=" + level+ "&" +
"s=" + s;
} //获取道路等POI,和影像地图配合使用
else if(mapStyle == "POI")
{
url = "http://mt"+(col%4)+".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);
} 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)
];
}
}
}

具体步骤如下:
第一步:将文件GoogleMapLayer.as放到com.esri.viewer包下

第二步:在MapManager.mxml文件中:
(1)引入包com.esri.viewer.GoogleMapLayer。

(2)在addLayerToMap函数中添加:

第三步:在LayerCreator.as文件中:
(1)引入包com.esri.viewer.GoogleMapLayer:

(2)在createLayer函数中添加:
else if (layerType == "googlemap")
{
return createGoogleLayer(layerCreationProperties);
}
(3)添加函数createGoogleLayer:

private static function createGoogleLayer(layerCreationProperties:LayerCreationProperties):GoogleMapLayer
{
var googleLayer:GoogleMapLayer=new GoogleMapLayer();
googleLayer.name=layerCreationProperties.label;
if (layerCreationProperties.style)
{
googleLayer.mapStyle= layerCreationProperties.style;
}
googleLayer.id=layerCreationProperties.label;
googleLayer.alpha=layerCreationProperties.alpha;
googleLayer.visible=layerCreationProperties.visible; return googleLayer;
}

第四步:在config.xml配置文件中添加basemaps:
<basemaps>
<layer label="GoogleMapLayer" type="GoogleMap" icon="assets/images/birds.png" style="Terrain" visible="true"/>
</basemaps>
运行结果:

作者:助你软件工作室
出处:http://www.cnblogs.com/chenyuming507950417/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
ArcGIS Viewer for Flex中引入google map作底图 (转)的更多相关文章
- ArcGIS Viewer for Flex中引入google map作底图
在ArcGIS Viewer for Flex开发中,经常需要用到google map作为底图,我们不能通过ArcGIS Viewer for Flex - Application Builder轻易 ...
- ArcGIS for Flex中引入google map作底图
上篇文章到在ArcGIS View中引入google map,这里讲ArcGIS for Flex中引入google map作底图. 同样道理,以google map作底图,需要编写继承自TiledM ...
- 基于ArcGIS Viewer for Flex开发的一款跨平台的应用程序
特点: 1.基于ArcGIS Viewer for Flex开发的一款跨平台的应用程序: -(IBAction) showTOC:(id)sender { if (_tocViewController ...
- Flex加载google地图、百度地图以及天地图作底图
一 Flex加载Google地图作底图 (1)帮助类GoogleLayer.as /* * 根据输入的地图类型加载Google地图(by chenyuming) */ package Layers ...
- arcgis api for silverlight使用google map等多个在线地图
原文 http://blog.csdn.net/leesmn/article/details/6820245 无可否认,google map实在是很漂亮.可惜对于使用arcgis api for si ...
- 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地图的情况下,成功显 ...
随机推荐
- BZOJ 2730:[HNOI2012]矿场搭建(割点+连通块)
[HNOI2012]矿场搭建 Description 煤矿工地可以看成是由隧道连接挖煤点组成的无向图.为安全起见,希望在工地发生事故时所有挖煤点的工人都能有一条出路逃到救援出口处.于是矿主决定在某些挖 ...
- python tornado对接权限中心的sdk封装
# -*- coding: utf-8 -*- import json import requests import logging as logger from python.akskapp.scr ...
- Linux命令之type,whatis,whereis,which,locate,find
第一个:type--查询一个命令的类型 -查询一个命令为内部或者外部命令的命令: -linux的众多命令中,有内部命令和外部命令,这时可以用type命令来查询一个命令到底是属于内部命令还是属于外部命令 ...
- Vijos P1007 绕钉子的长绳子
绕钉子的长绳子 背景 平面上有N个圆柱形的大钉子,半径都为R,所有钉子组成一个凸多边形. 现在你要用一条绳子把这些钉子围起来,绳子直径忽略不计. 描述 求出绳子的长度 格式 输入格式 第1行两个数:整 ...
- OwnCloud 搭建
owncloud 的安装方式可以在 [ 官网 ] 找到. 本文会说明 owncloud 在 CentOS 7.x 上基于 LAMP 安装, 以及简单的用 docker 镜像启动的例子. 基于 LAMP ...
- classes could not be found: - android.support.v7.internal.app.WindowDecorActionBar问题的解决方法
转载至----http://my.oschina.net/u/2425146/blog/546649?fromerr=aDYrFDVx.仅作个人收藏使用,有转载的朋友请连续原作者,谢谢 刚刚进入stu ...
- 积木大赛(NOIP2013)(纯贪心+模拟)
好吧,这道题也是..醉了. 其实题目编程挺水的,但是贪心过程不好想. 原题传送门 这道题对于任何一个点a[i]如果a[i]<a[i-1]的话,那么假设a[i-1]的高度为X,a[i]的高度为y, ...
- Unicode 和 ANSI
Project Properties -> General-> Character set,里面显示了是不是unicode. Unicode处理String的方式不一样,一定要注意!! ...
- hdu 2112(字典树+最短路)
HDU Today Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 转化一个数字数组为function数组(每个function都弹出相应的数字)
从汤姆大叔的博客里看到了6个基础题目:本篇是第2题 - 转化一个数字数组为function数组(每个function都弹出相应的数字) 此题关键点: 1.如何将一个匿名函数存入数组? 2.如何锁住需要 ...