ArcGIS API for Flex (set map spatial extent)

Source: Internet
Author: User

Reference Address: https://developers.arcgis.com/flex/guide/using-extent.htm

This tutorial describes several ways to set the extent of a map and how to get it for other operations.

Setting an extentsetting an initialized map extent differs from the default. Figure 1 is the default, Figure 2 is set, you can use the extent property or the extent class

using the extent propertyTo set the extent property in map, refer to the following code snippetFirst step: Insert <esri:Extent>tag, specifying the ID and coordinates coordinates.
Step Two: Add <esri:ArcGISDynamicMapServiceLayer>标记.

<?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 "xmlns:esri="/HTTP/ Www.esri.com/2008/ags "><fx:declarations><esri:spatialreference id=" WGs "wkid=" 4326 "/><esri: Extent id= "Extentofkansas" spatialreference= "{WGS}" xmax= " -94" xmin= " -103" ymax= "All" ymin= "$"/></fx:d Eclarations><esri:map id= "MyMap" extent= "{Extentofkansas}" ><esri:arcgistiledmapservicelayer url= "http ://server.arcgisonline.com/arcgis/rest/services/esri_streetmap_world_2d/mapserver "/><esri: Arcgisdynamicmapservicelayer id= "Mylayer" url= "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/ Petroleum/kgs_oilgasfields_kansas/mapserver "/></esri:map></s:application>
Another way to use the extent class

添加 <esri:SpatialReference> tag, specifying the coordinate point Wkid setting ID.

Insert<esri:extent> tags, specifying ID and coordinates coordinates.

Add<ArcGISTiledMapServiceLayer>Mark. 

<?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"   xmlns:esri= "http// Www.esri.com/2008/ags "><fx:declarations><esri:spatialreference id=" WGs "wkid=" 4326 "/></fx:d Eclarations><esri:map id= "MyMap" ><esri:extent><esri:extent spatialreference= "{WGS}" xmax= "-94" Xmin= " -103" ymax= "ymin=" "/></esri:extent><esri:arcgistiledmapservicelayer url="/http/ Server.arcgisonline.com/arcgis/rest/services/esri_streetmap_world_2d/mapserver "/><esri: Arcgisdynamicmapservicelayer id= "Mylayer" url= "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/ Petroleum/kgs_oilgasfields_kansas/mapserver "/></esri:map></s:application>
Or in the following ways

<?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 "xmlns:esri="/HTTP/ Www.esri.com/2008/ags "><esri:map id=" MyMap "><esri:extent><!--Map's current view corresponds to the geographic coordinate range--><ESRI: Extent xmax= " -6815000" xmin= " -14298000" ymax= "7117000" ymin= "2748000" ><esri:spatialreference wkid= "102100"/ ></esri:extent></esri:extent><esri:arcgistiledmapservicelayer url= "/http Server.arcgisonline.com/arcgis/rest/services/world_physical_map/mapserver "/></ESRI:MAP></S: Application>
Setting an extent when using multiple servicesWhen multiple services are using the same scope

In some cases, you might want to set the spatial extent of a layer instead of the initialization layer or basemap, and to do this, set the extent property of the map on the desired layer, we use 2 layers in the code below, the first is a basemap (ArcGIS Online world extent), The second one is the Kaiserslautern layer (the state of Kansas)

Set the extent of the Kaiserslautern state, add a Load property, and then set the extent (range) on the map

load= "mymap.extent = mykansaslayer.fullextent"

When the map is created, the Load property is loaded, and then theKansas Layer (Kaiserslautern State)Sets the global extent. The following code fragment uses the fullExtentTo set up map extent

<?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"   xmlns:esri= "http// Www.esri.com/2008/ags "><esri:map id=" MyMap "><esri:arcgistiledmapservicelayer url="/http/ Server.arcgisonline.com/arcgis/rest/services/esri_streetmap_world_2d/mapserver "/><esri: Arcgisdynamicmapservicelayer id= "Mykansaslayer" load= "mymap.extent = mykansaslayer.fullextent"   url= "/http/ Sampleserver1.arcgisonline.com/arcgis/rest/services/petroleum/kgs_oilgasfields_kansas/mapserver "/></esri :map></s:application>


Set initial extent instead of  full extent, using   mykansaslayer.initialextent

Getting The current extent

Gets the extent on the current map using the extent property.

Listening to extent changesMonitor extent changes, when users drag a map or zoom map each time on the map, it triggers a Extentevent event, you can add an event listener, using Mxml or ActionScript, to notify each extent change, referring to the following example

  • MXML Example:

    <esri:map id="MyMap" extentchange="Displayextent ()">  <esri:arcgistiledmapservicelayer url="Http://server.arcgisonline.com/ArcGIS/rest/services/Esri_streetmap_world_2d/mapserver " /></esri:Map>
  • actionscript Example:

    mymap.addeventlistener (Extentevent.extent_change, Extentchangehandler);  




ArcGIS API for Flex (set map spatial extent)

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.