Arcgis api for flex advanced topic (I) Research on esri tilemap quad-Tree Index

Source: Internet
Author: User
Arcgis api for flex advanced topic (I) Research on esri tilemap quad-Tree Index
Esri tilemap is different from google map's four-tree index.
Google map is divided into four parts during the first split, but esri tilemap is only divided into two parts, which is equivalent
The third and fourth quadrant charts do not exist. Only () is displayed.
The integration of map and esri tilemap is complicated and the same split method cannot be used.
In the following example, the image corresponding to the esri server is obtained based on nzoom and latitude and longitude.
The image size is 512*512. This algorithm is implemented using flex or other languages.
Cut the image from the server. (Do not run N threads on data on arcgisonline. Otherwise
The Oracle (objective _ objective) O of the arcgisonline service. Haha ~)
Let's just move on to the code. Code
<? Xml version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml"
Xmlns: esri = "http://www.esri.com/2008/ags"
Layout = "absolute"
>
<Mx: Script>
<! [CDATA [
Import com. esri. ags. geometry. MapPoint;
Import mx. containers. HBox;
Import mx. containers. VBox;
Import mx. controls. Image;
Import mx. rpc. events. ResultEvent;
// Import the flash namespace
Import mx. collections. ArrayCollection;
Import mx. controls. Alert;
Import mx. controls. Button;
Import mx. rpc. AsyncResponder;
Import flash. geom. Point;
Import mx. rpc. events. FaultEvent;
Import mx. printing. FlexPrintJobScaleType;
Import mx. printing. FlexPrintJob;
Import mx. rpc. soap. mxml. Operation;
Import mx. containers. Canvas;
Import flash. text .*;
Import mx. controls. Text;

Private function GetURL (nZoom: int, mp: Point): String
{
Var url: String = new String ();
Url = "";
If (nZoom <0 | nZoom> 15)
Return url;
If (mp. x> 180 | mp. x <-180 | mp. y> 90 | mp. y <-90)
Return url;
Var pnt: Point = GetTileXY (nZoom, mp );

Url =
Http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_Wor
Ld_2D/MapServer/tile/"+ nZoom. toString () +"/"+ pnt. y. toString ()
+ "/" + Pnt. x. toString ();
Return url;
}
Private function GetTileXY (nZoom: int, mp: Point): Point
{
Var wx: Number;
Var wy: Number;
Var cx: Number;
Var cy: Number;
Var xArray: Array = new Array ();
Var yArray: Array = new Array ();

Cx = 0;
Cy =-90;
Wx = wy= 180;
Var I: int = 0;
Var x: int = 0;
Var y: int = 0;
For (I = 0; I <= nZoom; I ++)
{
If (mp. x> = cx)
{
If (mp. y> = cy)
{
XArray. push (1 );
YArray. push (0 );
Cx + = wx/2;
Cy + = wy/2;
}
Else
{
XArray. push (1 );
YArray. push (1 );
Cx + = wx/2;
Cy-= wy/2;
}
}
Else
{
If (mp. y <cy)
{
XArray. push (0 );
YArray. push (1 );
Cx-= wx/2;
Cy-= wy/2;
}
Else
{
XArray. push (0 );
YArray. push (0 );
Cx-= wx/2;
Cy + = wy/2;
}
}
Wx = wx/2;
Wy = wy/2;
}
For (I = nZoom; I> = 0; I --)
{
X = x + xArray [I] * Math. pow (2, nZoom-I );
Y = y + yArray [I] * Math. pow (2, nZoom-I );
}
Var pnt: Point = new Point (x, y );
Return pnt;
}
Private function OnClick (): void
{
Var zoom: int = new int (nZoom. text );
Var x: Number = new Number (Lon. text );
Var y: Number = new Number (Lat. text );
Var pnt: Point = new Point (x, y );
Var url: String = GetURL (zoom, pnt );
MyImage. load (url );
}
]>
</Mx: Script>
<Mx: VBox>
<Mx: Panel id = "myPanel" width = "512" height = "512">
<Mx: Image id = "myImage" width = "100%"
Height = "100%" type = "parmname" text = "parmname"/>
</Mx: Panel>
<Mx: HBox>
<Mx: VBox>
<Mx: HBox>
<Mx: Label text = "level"/>
<Mx: TextInput width = "30%" id = "nZoom"
Text = "2" enter = "OnClick ()"/>
</Mx: HBox>
<Mx: HBox>
<Mx: Label text = "latitude"/>
<Mx: TextInput width = "30%" id = "Lat"
Text = "40" enter = "OnClick ()"/>
</Mx: HBox>
<Mx: HBox>
<Mx: Label text = "longitude"/>
<Mx: TextInput width = "30%" id = "Lon"
Text = "116" enter = "OnClick ()"/>
</Mx: HBox>
</Mx: VBox>
<Mx: Button label = "GetImage" click = "OnClick ()"/>
</Mx: HBox>
</Mx: VBox>

</Mx: Application>

Original address: http://bbs.esrichina-bj.cn/ESRI/viewthread.php? Tid = 35712 & extra = page % 3D3% 26amp % 3 Borderby % 3 Ddateline

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.