如何使用ArcGIS API for Flex 调用天地图

2024-11-03 18:18:24
推荐回答(4个)
回答1:

本文讲述如何使用ArcGIS API for Flex调用天地图的服务,那么下面我就把代码共享给大家。 实现的方式主要是扩展ArcGIS API for Flex中的TiledMapLayer,去读取天地图冲告的切片: packagecom.esrichina { importcom.esri.ags.SpatialReference; importcom.esri.ag

本文讲述如何使用ArcGIS API for Flex调散备明用天地图的服务,滚滚那么下面我就把代码共享给大家。 实现的方式主要是扩展ArcGIS API for Flex中的TiledMapLayer,去读取天地图的切片:
package com.esrichina { import com.esri.ags.SpatialReference; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.MapPoint; import com.esri.ags.layers.LOD; import com.esri.ags.layers.TileInfo; import com.esri.ags.layers.TiledMapServiceLayer; import flash.net.URLRequest; public class tdtMapslayer extends TiledMapServiceLayer { public function tdtMapslayer() { super(); buildTileInfo(); setLoaded(true); } private var _tileInfo:TileInfo=new TileInfo(); private var _baseURL:String=""; override public function get fullExtent():Extent { return new Extent(-180, -90, 180, 90, new SpatialReference(4326)); } override public function get initialExtent():Extent { return new Extent(-180, -90, 180, 90, new SpatialReference(4326)); } override public function get spatialReference():SpatialReference { return new SpatialReference(4326); } override public function get tileInfo():TileInfo { return _tileInfo; } override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest { var url:String="http://tile2.tianditu.com/DataServer?T=A0512_EMap&" + "X=" + col + "&" + "Y=" + row + "&" + "L=" + level; return new URLRequest(url); } private function buildTileInfo():void { _tileInfo.height=256; _tileInfo.width=256; _tileInfo.origin=new MapPoint(-90 ,45 ,new SpatialReference(4326)); _tileInfo.spatialReference=new SpatialReference(4326); _tileInfo.lods = [ new LOD(1, 0.3515625, 147748799.285417), new LOD(2, 0.17578125, 73874399.6427087), new LOD(3, 0.087890625, 36937199.8213544), new LOD(4, 0.0439453125, 18468599.9106772), new LOD(5, 0.02197265625, 9234299.95533859), new LOD(6, 0.010986328125, 4617149.97766929), new LOD(7, 0.0054931640625, 2308574.98883465), new LOD(8, 0.00274658203125, 1154287.49441732), new LOD(9, 0.001373291015625, 577143.747208662), new LOD(10, 0.0006866455078125, 288571.873604331), new LOD(11, 0.00034332275390625, 144285.936802165), new LOD(12, 0.000171661376953125, 72142.9684010827), new LOD(13, 8.58306884765629E-05, 36071.4842005414), new LOD(14, 4.29153442382814E-05, 18035.7421002707), new LOD(15, 2.14576721191407E-05, 9017.87105013534), new LOD(16, 1.07288360595703E-05, 4508.93552506767), new LOD(17, 5.36441802978515E-06, 2254.467762533835), new LOD(18, 2.68220901489258E-06, 1127.2338812669175) ]; } } }

回答2:

需要下载安装 arcgis server api for flex
如果只是加载地图扰樱,很简单的姿陆,如果需要别的功能,就需要仔细研究下了。esri网上都缓册丛提供了常见功能的demo。
稍后帮你提供点链接~~

回答3:

继猜简承 TiledMapServiceLayer 编写SXGeoTileLayer 类信兄
package ext
{

import com.esri.ags.SpatialReference;
import com.esri.ags.geometry.Extent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.layers.supportClasses.LOD;
import com.esri.ags.layers.supportClasses.TileInfo;
import com.esri.ags.layers.TiledMapServiceLayer;
import com.esri.ags.layers.TiledMapServiceLayer;

import flash.geom.Point;
import flash.net.URLRequest;

/**
* SXGeoTileLayer 吉奥的地图服务
*/
public class SXGeoTileLayer extends TiledMapServiceLayer
{
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------

/**
* Creates a new PortlandTiledMapServiceLayer object.
*/
public function SXGeoTileLayer()
{
super();

buildTileInfo(); // to create our hardcoded tileInfo

setLoaded(true); // Map will only use loaded layers
}

//--------------------------------------------------------------------------
//
// Variables
//
//--------------------------------------------------------------------------

private var wkid:int = 4326;
private var _tileInfo:TileInfo = new TileInfo(); // see buildTileInfo()
private var _url:String = new String();
//private var _wmsLayer:String = new String();

//穗坦裤--------------------------------------------------------------------------
//
// Overridden properties
// fullExtent()
// initialExtent()
// spatialReference()
// tileInfo()
// units()
//
//--------------------------------------------------------------------------

//----------------------------------
// fullExtent
// - required to calculate the tiles to use
//----------------------------------

override public function get fullExtent():Extent
{
return new Extent(-180, -90, 180, 90, new SpatialReference(4326));
//return new Extent(65.94,18.84,137.74,62.85, new SpatialReference(4326));
}

//----------------------------------
// initialExtent
// - needed if Map doesn't have an extent
//----------------------------------

override public function get initialExtent():Extent
{
return new Extent(-124.731422,24.955967,-66.969849, 49.371735,new SpatialReference(4326));
//return new Extent(112.48,47.77,112.60,47.97, new SpatialReference(4326));
}

//----------------------------------
// spatialReference
// - needed if Map doesn't have a spatialReference
//----------------------------------

override public function get spatialReference():SpatialReference
{
return new SpatialReference(4326);
}

//----------------------------------
// 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";
}

//--------------------------------------------------------------------------
//
// Overridden methods
// getTileURL(level:Number, row:Number, col:Number):URLRequest
//
//--------------------------------------------------------------------------

override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest
{
var url:String ;
url = _url + "&X=" + col.toString() + "&Y=" + row.toString()+ "&L="+ level.toString();
return new URLRequest(url) ;
}

//--------------------------------------------------------------------------
//
// Private Methods
//
//--------------------------------------------------------------------------

private function buildTileInfo():void
{
_tileInfo.height = 256;
_tileInfo.width = 256;
_tileInfo.origin = new MapPoint(-180, 90);
_tileInfo.spatialReference = new SpatialReference(4326);
_tileInfo.lods = [
//new LOD(0, 1.40625, 590995197.1416691),
new LOD(1, 0.703125, 295497598.5708346),
new LOD(2, 0.3515625, 147748799.2854173),
new LOD(3, 0.17578125, 73874399.64270864),
new LOD(4, 0.087890625, 36937199.82135432),
new LOD(5, 0.0439453125, 18468599.91067716),
new LOD(6, 0.02197265625, 9234299.95533858),

new LOD(7, 0.010986328125, 4617149.97766929),
new LOD(8, 0.0054931640625, 2308574.98883465),
new LOD(9, 0.00274658203124999, 1154287.49441732),
new LOD(10, 0.001373291015625, 577143.747208662),
new LOD(11, 0.0006866455078125, 288571.873604331),
new LOD(12, 0.000343322753906249, 144285.936802165),
new LOD(13, 0.000171661376953125, 72142.9684010827),
new LOD(14, 0.0000858306884765626, 36071.4842005414),
new LOD(15, 0.0000429153442382813, 18035.7421002707),
new LOD(16, 0.0000214576721191406, 9017.87105013534),
];
}

private function padString(text:String, size:int, ch:String):String
{
while (text.length < size)
{
text = ch + text;
}
return text;
}
public function set url(val:String):void
{
this._url = val;
}
}
}

回答4:

首先确认一下,你是不是散派用flexviewer来访问天地图里面发布的地图服务?如果是那样,只需要把flexviewer里面瞎睁的config.xml中的basemap和其它服务替换成你需要访问的天地图磨掘岁服务地址就可以了。Good luck~