ArcGIS Server Flex API接入百度地图
分享
本实例只是个人兴趣研究,如果想要应用到商业用途,请联系相关厂家)
ArcGIS Server Flex API接入百度地图,是基于地图切片访问原理进行加载,需要ArcGIS Server Flex API重写TiledMapServiceLayer类,接入的地图包括矢量图、交通的POI点及影像图,实现代码如下:
接入矢量地图:
接入混合模式地图:
文章来源:http://blog.csdn.net/sydbc/article/details/17021771
ArcGIS Server Flex API接入百度地图,是基于地图切片访问原理进行加载,需要ArcGIS Server Flex API重写TiledMapServiceLayer类,接入的地图包括矢量图、交通的POI点及影像图,实现代码如下:
package com.esri.viewer.components.common.baidu
{
import com.esri.ags.SpatialReference;
import com.esri.ags.geometry.Extent;
import com.esri.ags.geometry.MapPoint;
importcom.esri.ags.layers.TiledMapServiceLayer;
importcom.esri.ags.layers.supportClasses.LOD;
import com.esri.ags.layers.supportClasses.TileInfo;
import flash.net.URLRequest;
import flashx.textLayout.formats.Float;
public class BaiduTiledMapServiceLayerextends TiledMapServiceLayer
{
//成员变量
private var_tileInfo:TileInfo = new TileInfo(); // see buildTileInfo()
private var _wkid:int= 102100;//102113;//102100;
private varcornerCoordinate:Number = 20037508.3427892;
private var_mapType:String = “Map”;
public functionBaiduTiledMapServiceLayer()
{
super();
buildTileInfo(); // to create our hardcoded tileInfo
setLoaded(true); // Map will only use loaded layers
}
//———————————-
// 全屏范围
// – requiredto calculate the tiles to use
//———————————-
override publicfunction get fullExtent():Extent
{
return new Extent(-cornerCoordinate, -cornerCoordinate, cornerCoordinate,cornerCoordinate, new SpatialReference(_wkid));
}
//———————————-
// 初始化范围
// – needed ifMap doesn”t have an extent
//———————————-
override publicfunction get initialExtent():Extent
{
return new Extent(-cornerCoordinate, -cornerCoordinate, cornerCoordinate,cornerCoordinate, new SpatialReference(_wkid));
}
//———————————-
// 空间参考系
// – needed ifMap doesn”t have a spatialReference
//———————————-
override publicfunction get spatialReference():SpatialReference
{
return new SpatialReference(_wkid);
}
//———————————-
// tileInfo
//———————————-
override publicfunction get tileInfo():TileInfo
{
return _tileInfo;
}
public function setmapType(strMapType:String):void
{
this._mapType = strMapType;
}
public function getmapType():String
{
return this._mapType;
}
//———————————-
// units
// – needed ifMap doesn”t have it set
//———————————-
/*
override publicfunction get units():String
{
return“esriDecimalDegrees”;
}//*/
//————————————————————————–
//
// 关键方法,用于读取服务器上的缓存图片
// getTileURL(level:Number, row:Number,col:Number):URLRequest
//
//————————————————————————–
override protectedfunction getTileURL(level:Number, row:Number, col:Number):URLRequest
{
var zoom:int = level – 1;
var offsetX:int = Math.pow(2, zoom) as int;
var offsetY:int = offsetX – 1;
var numX:int = col – offsetX;
var numY:int = (-row) + offsetY;
zoom = level + 1;
var num:int = (col + row) % 8 + 1;
var url:String = null;
if (mapType == “Map”)
{
url = “http://q” + num + “.baidu.com/it/u=x=” + numX + “;y=” + numY + “;z=” +zoom + “;v=009;type=web&fm=44″;
}
else if (mapType == “Image”)
{
url = “http://q”+num+”.baidu.com/it/u=x=”+numX+”;y=”+numY+”;z=”+zoom+”;v=009;type=sate&fm=46″;
}
else if (mapType == “POI”)
{
url =“http://q”+num+”.baidu.com/it/u=x=”+numX+”;y=”+numY+”;z=”+zoom+”;v=009;type=trans&fm=47″;
}
return new URLRequest(url);
}
//————————————————————————–
//
// 自定义方法,定义地图缩放等级
//
//————————————————————————–
private functionbuildTileInfo():void
{
_tileInfo.height=256;
_tileInfo.width=256;
_tileInfo.origin=new MapPoint(-cornerCoordinate, cornerCoordinate);
_tileInfo.spatialReference=new SpatialReference(_wkid);
_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)
];
}
}
}
接入矢量地图:
接入混合模式地图:
文章来源:http://blog.csdn.net/sydbc/article/details/17021771
0 个评论
推荐内容
- ArcGIS Pro 2.4向独立server发布服务步骤
- Linux上安装ArcGIS Enterprise超详细教程——以Redhat7.2上安装ArcGIS Enterprise 10.5为例
- ArcGIS for Server 10.x 许可授权手册
- Portal for ArcGIS 10.X许可授权手册 (Windows版)
- arcgis server 无法手动删除切片
- ArcGIS for Server内置JS Viewer的离线部署和配置
- Linux上安装ArcGIS for Server超详细教程——以Redhat6.5上安装ArcGIS for Server 10.3.1为例
- 如何创建Geometry Service?
- 地图服务优化策略
相关问题
- 如何优雅的使用ArcGIS知乎?
- 建设ArcGIS知乎平台的目和意义?
- ArcGIS知乎社区改进意见征集
- 【抽奖结果已出】ArcGIS知乎社区活动 之 你不知道的地理空间革命【转发分享有奖】【附奖品寄送照片】
- 有谁知道哪里可以免费获取各省市地图数据呢,包括详细的shape文件数据
- 苹果系统下可以使用arcgis 吗?
- 请问ArcGIS适合在局域网内用javaweb做二次开发吗?
- arcgis版本兼容性
- 请问大神们,怎么用ArcGIS做城镇间经济联系强度的图?
- ArcGIS如何求栅格图像的“质心”
- 在Visual studio 2015 中使用 Arcgis API for JavaScript v3.16 如何实现代码智能提示?