效果如下:
MapABCTileMapServiceLayer.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.TiledMapServiceLayer;
import com.esri.ags.layers.supportClasses.LOD;
import com.esri.ags.layers.supportClasses.TileInfo;
import flash.net.URLRequest;
public class MapABCTileMapServiceLayer extends TiledMapServiceLayer
{
//成员变量
private var _tileInfo:TileInfo = new TileInfo(); // see buildTileInfo()
public function MapABCTileMapServiceLayer()
{
super();
buildTileInfo(); // to create our hardcoded tileInfo
setLoaded(true); // Map will only use loaded layers
}
//----------------------------------
// 全屏范围
// - required to calculate the tiles to use
//----------------------------------
override public function get fullExtent():Extent
{
return new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, new SpatialReference(102113));
}
//----------------------------------
// 初始化范围
// - needed if Map doesn't have an extent
//----------------------------------
override public function get initialExtent():Extent
{
return new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, new SpatialReference(102113));
}
//----------------------------------
// 空间参考系
// - needed if Map doesn't have a spatialReference
//----------------------------------
override public function get spatialReference():SpatialReference
{
return new SpatialReference(102113);
}
//----------------------------------
// tileInfo
//----------------------------------
override public function get tileInfo():TileInfo
{
return _tileInfo;
}
//----------------------------------
// units
// - needed if Map doesn't have it set
//----------------------------------
/*
override public function get units():String
{
return "esriDecimalDegrees";
}//*/
//--------------------------------------------------------------------------
//
// 关键方法,用于读取服务器上的缓存图片
// getTileURL(level:Number, row:Number, col:Number):URLRequest
//
//--------------------------------------------------------------------------
override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest
{
//col%4是让其生成随机的0-3之间的数,缓存在0-3上都有相同的备份
// http://emap0.mapabc.com/mapabc/maptile?v=w2.61&x=845&y=387&z=10
var url:String = "http://emap"+(col%4)+".mapabc.com/mapabc/maptile?v=w2.61&&"+
"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);
_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)
];
}
}
}
ArcGISMapABCMap.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:mapabc="com.esri.arcgis.flex.sample.*"
xmlns:esri="http://www.esri.com/2008/ags">
<esri:Map>
<mapabc:MapABCTileMapServiceLayer id="googleMap" />
</esri:Map>
</s:Application>
- 大小: 146.7 KB
分享到:
相关推荐
在ArcGIS Flex API中使用天地图的地名搜索服务。源代码中通过ArcGIS Flex API封装了TianDiTuLocationTask类,接口类似ArcGIS Flex API中task类。
arcgis flex api 2.5 最新
分别用ArcGIS Flex API和SuperMap Flex API实现的军标箭头库,有需要源码的可回复邮箱索取。
arcgis flex api 3.0 离线帮助文档chm格式 绝对好用!
建立基于ArcGIS Flex API的地图应用 ArcGIS Server 开发概要 ArcGIS Server REST API ArcGIS API For Flex...
ArcGIS Flex API—高级篇 聚合 编辑 皮肤 编写库 移动设备 数据传输
ArcGis-10.1 读取 天地图 API 接口工具 使用说明文档 20130425.rar
arcgis api for flex 开发入门(三)地图浏览控件的使用
ArcGIS Flex API初级篇,对Flex的初级讲解
ArcGIS Flex API和Java API的集成 esri的培训资料
ArcGIS Flex API 中的 Flex 技-面向对象
ArcGIS Flex API 中的 Flex 技术-异步特征
ArcGIS Flex API 中的 Flex 技-xml解析
ArcGIS API for FLEX全部代码实例
Arcgis flex api自定义风场点图标样式
ARCGIS Flex API 2.4版本 离线帮助
arcgis flex api 3.0 官方正式版, 包含范例。
基于ArcGIS Flex API开发Flex AIR Mobile应用
ArcGIS Flex API 2.0 离线参考 EXE格式
ArcGis-10.1 读取 天地图 Flex API 接口工具 20130425