Arcgis api for flex Development (2) map creation

Source: Internet
Author: User

Arcgis api for flex Development (2) map creation
To create an esri map in flex, you only need to use the <esri: Map> label.
In the <esri: Map> tab, you can add attributes and event response messages.
As follows:
<Esri: Map width = "100%" height = "50%" id = "EsriMap" creati resize = "EsriMapResize (event);" extentChange = "ESRIMapExtentChange (event ); "mouseMove =" OnDrawMouseMove (event) "/>
The size of the map defined by width and height. id = "EsriMap" uniquely identifies this map.
There are also many messages for map, the most common is creationComplete, resize and mouse message.
Now that we have map, how can we let her display data? This requires adding a layer sub-tag to the <esri: Map> tag.
There are several types of layers in the ags flex api.
ArcGISDynamicMapServiceLayer: Allows you to work with a dynamic map service resource exposed by the ArcGIS Server rest api.
ArcGISImageServiceLayer: Allows you to work with an image service resource exposed by the ArcGIS Server rest api.
ArcGISMapServiceLayer: The base class for ArcGIS Server map services.
ArcGISTiledMapServiceLayer: Allows you to work with a cached map service resource exposed by the ArcGIS Server rest api.
ArcIMSMapServiceLayer: Allows you to work with an ArcIMS image service.
GPResultImageLayer: Allows you to view a geoprocessing task result identified by jobId and parameterName.
GraphicsLayer: A layer that contains one or more Graphic features.
GraphicsLayer supports adding Graphic features layers on the client. You need to add all the elements generated in the client or interactive operations to this layer.
Next, we will add an ArcGISTiledMapServiceLayer and GraphicsLayer to map.

<Esri: Map width = "100%" height = "50%" id = "EsriMap" creati resize = "EsriMapResize (event);" extentChange = "ESRIMapExtentChange (event ); "mouseMove =" OnDrawMouseMove (event) ">
<Esri: ArcGISTiledMapServiceLayer url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
<Esri: GraphicsLayer id = "myGraphicsLayer" spatialReference = "{sr}"/>
</Esri: Map>
The url attribute in the <esri: ArcGISTiledMapServiceLayer> label is the address that provides the service. The spatialReference attribute in the <esri: GraphicsLayer> label defines the spatial reference system of the layer.
To create a spatial reference system, you only need to use the <esri: SpatialReference> label. wkid is the ID of the space test system defined by esri, the specific ID corresponds to the space reference can be in the http://resources.esri.com/help/9.3/arcgisserver/apis/REST/index.html? Gcs.html. Create a kid = "4326" spatial reference system.
<Esri: SpatialReference id = "sr" wkid = "4326" type = "codeph" text = "codeph"/>
So how do we define the range we want to display?
Simply add the <esri: extent> sub-tag under <esri: Map> to control the current display range.
<Esri: extent>
<Esri: Extent id = "esriMapExtent" xmin = "116" ymin = "39.5" xmax = "116.5" ymax = "40.5"/>
</Esri: extent>
X is the longitude, and y is the latitude.
In this way, a map in Beijing can be displayed in front of us.
The complete code is as follows:

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"

PageTitle = "Using ArcGIS API for Flex to connect to a cached ArcGIS Online service"

StyleName = "plain">

<Esri: SpatialReference id = "sr" wkid = "4326" type = "codeph" text = "codeph"/>

<Esri: Map crosshairVisible = "true">

<Esri: extent>

<Esri: Extent id = "esriMapExtent" xmin = "116" ymin = "39.5" xmax = "116.5" ymax = "40.5"/>

</Esri: extent>

<Esri: ArcGISTiledMapServiceLayer

Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>

<Esri: GraphicsLayer id = "myGraphicsLayer" spatialReference = "{sr}"/>

</Esri: Map>

</Mx: Application>

 

Original address: http://bbs.esrichina-bj.cn/ESRI/viewthread.php? Tid = 35537 & extra = page % 3D4% 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.