如何使用ArcGIS API for Flex 调用天地图
2个回答
展开全部
本文讲述如何使用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),
本文讲述如何使用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),
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
2015-04-08 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517171
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
继承 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;
}
}
}
前台页面
<?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"
minWidth="955"
minHeight="600"
creationComplete="init()" xmlns:esri="http://www.esri.com/2008/ags">
<fx:Script>
<![CDATA[
import ext.SXGeoTileLayer;
private function init():void{
var wmslayer:SXGeoTileLayer=new SXGeoTileLayer();
wmslayer.url=" http://tile0.tianditu.com/DataServer?T=A0610_ImgAnno";
map.addLayer(wmslayer);
var wmslayer1:SXGeoTileLayer=new SXGeoTileLayer();
wmslayer1.url=" http://tile0.tianditu.com/DataServer?T=sbsm0210";
map.addLayer(wmslayer1);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<esri:Map id="map">
</esri:Map>
</s:Application>
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;
}
}
}
前台页面
<?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"
minWidth="955"
minHeight="600"
creationComplete="init()" xmlns:esri="http://www.esri.com/2008/ags">
<fx:Script>
<![CDATA[
import ext.SXGeoTileLayer;
private function init():void{
var wmslayer:SXGeoTileLayer=new SXGeoTileLayer();
wmslayer.url=" http://tile0.tianditu.com/DataServer?T=A0610_ImgAnno";
map.addLayer(wmslayer);
var wmslayer1:SXGeoTileLayer=new SXGeoTileLayer();
wmslayer1.url=" http://tile0.tianditu.com/DataServer?T=sbsm0210";
map.addLayer(wmslayer1);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<esri:Map id="map">
</esri:Map>
</s:Application>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询