ArcGIS With Flex
ArcGIS With Flex
htm
Version 3.7
The steps below will guide you through displaying a map with a basemap layer in your
application. We assume that you have already created a blank project with the referenced API
library as discussed in the Getting started section.
The primary way to display geographic information in your application is through a map. The
Flex API provides a user interface (UI) Map component. This component lets you display
content by either working with layers referencing various web services such as ArcGIS Server
Map and image services, Open Street Map, Bing Maps, OGC WMS etc. or by referencing
preconfigured web maps from ArcGIS Online (Esri's cloud), or your own on-premise ArcGIS
portal(s).
Flex applications are developed using the MXML and ActionScript languages with the
ActionScript class library. MXML can be compared to HTML, as it uses tags to lay out the page.
Whereas Actionscript can be compared to Javascript, as this is where the code and logic usually
reside.
We are going to work strictly in MXML for this tutorial by adding a map UI component to the
project initially created in the Getting started topic.
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
xmlns:esri="http://www.esri.com/2008/ags">
</s:Application>
Now that you added the namespace reference to your markup. You can begin writing
code.
Add the following markup in the Editor view underneath the namespace reference added
above.
Next, add the ArcGISTiledMapServiceLayer as the basemap layer to the map. Add
theArcGISDynamicMapServiceLayer displaying world population density onto the basemap
layer.
....
<esri:Map level="3" wrapAround180="true">
<esri:center>
<esri:WebMercatorMapPoint lon="0" lat="0"/>
</esri:center>
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/
World_Street_Map/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/
Demographics/ESRI_Population_World/MapServer"
alpha=".70"/>
</esri:Map>
The MXML above adds the esri:Map component to the application with a set level and center. In
addition to the Map container, you are also adding a tiled map service layer pointing to a REST
URL hosting a cached map service and a dynamic map service layer. Upon launching the
application, the map displays the tiled map service layer at the third level of detail centered on a
latitude and longitude of zero with the dynamic map service layer layered on top.
Tip:
Remember when writing code, it should always contain at least a namespace andActionScript
code and/or MXML tags.
Quick overview
Version 3.7
Quick overview
An ArcGIS web map is a basemap and a related set of layers that users can interact with to
perform some meaningful task. These maps are available to a wide audience and include
multiscale basemaps, operations layers targeted to a specific audience, and pop-up windows that
allow users to focus on specific features of interest, as well as other data formats (text files,
shapefiles, KML, etc). These web maps are viewable on a wide variety of clients including
mobile devices, desktop applicaitons, and web browsers. For more information regarding
working with ArcGIS Online web maps, see the ArcGIS.com Help section.
Note:
This tutorial assumes that you are familiar with creating web maps. If you are not, see the Create
a web map tutorial.
After creating the web map, copy the web map ID to use within this tutorial. To find the ID, view
your web map in either ArcGIS.com or, if applicable, Portal for ArcGIS, and notice that the URL
includes the unique map identifer. An example of this is displayed below.
The following steps assume you have completed the steps necessary to create a new project and
add the Flex API library as discussed in the Getting started topic.
1. In Flash Builder, create a new project and make certain to add the Flex API library.
2. In the Editor View add the following code. Also make certain to reference the esrinamespace.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
You should now have a web application displayed similarly to the screen capture above.
Conceptually, this is how the code breaks down:
The initializeHandler is fired when the application initializes and the map is created
using the provided web map ID, e.g. 4778fee6371d4e83a22786029f30c7e1.
Once the map is created and complete, the createMapByIdCompleteHandler is fired. This
event calls the Spark container's addElement function passing in the map.
Note:
The ID is provided as an example, you can swap this out for one of your own.
Version 3.7
Copyright 2016 Esri. All rights reserved.
The following steps assume you have completed the steps necessary to create a new project and
add the Flex API library as discussed in the Getting started topic.
1. In Flash Builder, create a new project and make certain to add the Flex API library and reference
the esri namespace.
2. In the Editor View, add the MXML below including reference to the layout tag.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18. Next, add the map, a tiled layer, and lastly a GraphicsLayer for the query results. The next
section will discuss QueryTask which is used in the graphicProvider.
19. ...
20. paddingTop="20"/>
21. </s:layout>
22.
Note:
It is not always necessary to work with a map when performing a query. Another example could
include populating a table with the query results. See this samplefor additional help on doing
this.
In order to access the QueryTask, you first need to set it to a URL of the layer that the query will
work against. The URL includes the layer ID. In the following code snippet, the layer ID is 0.
<fx:Declarations>
<!-- Layer with US States -->
<esri:QueryTask id="queryTask"
showBusyCursor="true"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA
/MapServer/5"
useAMF="false"/>
<esri:Query id="query"
outSpatialReference="{myMap.spatialReference}"
returnGeometry="true"
text="{qText.text}">
<esri:outFields>
<fx:String>MED_AGE</fx:String>
<fx:String>POP2007</fx:String>
</esri:outFields>
</esri:Query>
</fx:Declarations>
<esri:Map id="myMap">
<esri:extent>
...
The query defines the criteria that will be used for executing the query.
SetreturnGeometry="true" if you wish to display the results of the query. In addition,
two fields are specified in the outFields . These two fields could then be displayed in the
output query results.
Tip:
The fewer fields included, the faster the response. Also, use the actual field names rather
than aliases, although aliases can be used in the output task results.
In Flash Builder's Editor view, add the following MXML snippet following
the<fx:Declarations> section.
...
</esri:Query>
</fx:Declarations>
<s:Panel height="60"
backgroundColor="0xB2BFC6"
title="Query a layer (search for a state)">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:TextInput id="qText"
width="100%"
enter="doQuery()"
text="California"/>
<s:Button click="doQuery()" label="Do Query"/>
</s:Panel>
<esri:Map id="myMap">
<esri:extent>
...
The TextInput allows input of a state name. Once this is entered, the doQuery() function
is called. This then executes the callback function onResult(). One of the arguments to
this function is a FeatureSet that contains the results of the query. The FeatureSet's
features can be directly assigned to the GraphicProvider of the graphics layer rendered
on the map.
In case of a failure, the callback function onFault() is called, which, in the following
example, shows an alert box with information about the failure.
Note:
For the purpose of this tutorial, the results are assigned to the GraphicProvider in the
MXML code, graphicProvider="{queryTask.executeLastResult.features}".
</fx:Script>
<fx:Declarations>
<!-- Layer with US States -->
You should now have a web application displayed similarly to the screen capture above.
Conceptually, this is how the code breaks down:
The queryTask is based off of a layer within a map service. In this case, a 'states' layer of
the US.
The query parameter is set to whatever text is input to the textbox.
The onResult() function is fired after successful completion of the queryTask which, in
turn, passes in the resulting FeatureSet.
The FeatureSet features, ie. graphics, are bound to graphicProvider and subsequently
displayed.
Mobile-specific application
In this topic
Prerequisites
Write code
Additional Information
Version 3.7
Prerequisites
In this tutorial you will create a basic Flex mobile application that displays a basemap. Before
doing this, you will need to make sure you have the following:
Flex users will need to download the original AIR SDK without the new compiler. Mac
users click here Windows users click here.
If this SDK is not listed, click the Configure Flex SDKs... link and browse to the location of the
newly configured SDK.
4. Under the Mobile Settings tab, check Google Android and keep the default settings and
click Next.
5. (Optional) click the Permissions button and you can specify which permissions are allowed on
the device at runtime. For the purpose of this tutorial, keep the defaults, click Next.
6. Under the Server Settings tab, keep all defaults, click Next.
7. Under the Build Paths tab, click Add SWC... and browse to the location of the downloaded Flex
API. Keep the defaults for folder, file, and ID names.
Note:
For the purpose of this tutorial, we are not changing the Application ID. This is not practical in a
real-world deployment scenario. Here, you would want to give your Application ID a fully
qualified domain name, e.g. com.mydomain.myApp.
Write code
Currently, the app does not contain anything. In this next section we will provide the code to add
a simple basemap to the app.
In Flash Builder, make certain the MyBaseMapHomeView.mxml (or whatever name you called
your application) tab is active and the file is visible.
Inside the Editor view, add the following code and save.
<?xml version="1.0" encoding="utf-8"?>
<s:View
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags"
title="A tiled map service">
<esri:Map id="myMap"
attributionVisible="false"
level="2"
wrapAround180="true"
zoomSliderVisible="false">
<esri:extent>
<esri:Extent xmin="-19325128" ymin="-10948057"
xmax="-539964" ymax="18364625">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</esri:Map>
</s:View>
Note:
If using version 3.4 or above, you may receive an error upon running, Class mx.controls::
DateField could not be found. Class com.esri.ags.skins.fieldClasses::CalendarField could not be
found . If this occurs, please see Mobile applications with Flex and/or the section discussing it in
theFAQs.
Additional Information
The steps provided above are given as a basic tutorial and are not all-encompassing. For further
information, please refer to Adobe's document for developing mobile applications.
The ArcGIS API for Flex provides mobile samples that demonstrate some of the above
functionality. If you wish to explore these samples, please see the ArcGIS API for Flex samples
on GitHub.
Note:
If you are using certain mx components, you will need to include the mx.swc among the project
libraries. You might also want to include sparkskins.swc. SeeMobile applications with Flex for
more information.
Caution:
There is a known-limit when working with pop-up windows in mobile applications created with
version 3.1. If doing so, please note that you will need to either: Add
both mx.swc and sparkskins.swc to your project, or update PopUpRendererSkin and remove
references to the RelationshipInspector.
Additional Resources
Version 3.7
Web editing requires a feature service to provide the symbology and feature geometry of your
data. Feature services allow you to create custom REST endpoints to store and query geographic
data such as points, lines and polygons. Store custom rendering rules and metadata such as place
names, ratings and addresses. Run analysis and computations against your stored data. Create
hosted tile sets with baked-in feature services.
The ArcGIS API for Flex provides a FeatureLayer that allows you to access and edit vector map
data. Feature services are accessible via a feature layer. Feature layers can do a variety of things
and can reference a layer in either a map service or a feature service. However, when you use a
feature layer for editing purposes you need to reference a layer in a feature service.
Web editing requires some initial setup of a feature service, which exposes information about a
layer's feature geometries and attributes. Also, geometry services can be used to accomplish
some Web editing tasks. In order to use the main Editor component, for example, you must have
a running geometry service.
When you perform editing, your Web application tells the feature layer which attributes have
changed and, if applicable, how the geometry changed. The feature layer also displays the
updated features after editing. The feature services can be hosted on ArcGIS Online (Esri's
cloud) or on your on-premise servers.
Note:
The following steps assume you have completed the steps necessary to create a new project and
add the Flex API library as discussed in the Getting started topic.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags"
<esri:Map id="myMap" wrapAround180="true">
<esri:extent>
<esri:Extent id="socal"
xmin="-13471000" ymin="3834000" xmax="-12878000" ymax="4124000">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:FeatureLayer id="incidentsAreas"
mode="snapshot"
outFields="[data_security,description]"
url="http://sampleserver6.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureS
erver/2"/>
22. </esri:Map>
...
23. In the Editor View, add the MXML below declaring the geometry service.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags"
<fx:Declarations>
<esri:GeometryService id="myGeometryService"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
</fx:Declarations>
<esri:Map id="myMap" wrapAround180="true">
<esri:extent>
</s:Application>
35. In the Editor View, add the MXML below including reference to the Editor component. This
component bundles much of the editing functionality up in one component so that all you need to
do is reference it within your code with a corresponding geometry service.
36. <esri:FeatureLayer id="incidentsAreas"
37.
mode="snapshot"
38.
outFields="[data_security,description]"
39.
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureS
erver/2"/>
40. </esri:Map>
41.
42.
<esri:Editor id="myEditor"
43.
width="100%" height="200"
44.
geometryService="{myGeometryService}"
45.
map="{myMap}"/>
46.
...
47. Next, add an initialize handler function and reference it within the application.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
...
xmlns:esri="http://www.esri.com/2008/ags"
initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
myEditor.featureLayers = [ incidentsAreas ];
}
]]>
</fx:Script>
68. Next, let's add a snippet working with the style tag. This allows us to slightly alter the
infowindow component that displays after creating a new feature.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
...
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace esri "http://www.esri.com/2008/ags";
Accessing data from the cloud is not difficult to accomplish while working with the Flex API. In
this particular example, we worked with the Editor component which handles a lot of the editing
complexity for you. We were able to create a simple web mapping application with access to
editable feature data in the cloud in just a matter of a few steps. Conceptually, this is how the
code breaks down:
Reference the map, add layers, and lastly get a reference to an editable feature service.
Get a reference to a geometry service since it works in conjunction with the Editor
component.
Instantiate the Editor component and set its associated geometry service and map.
Wire the application's initialize handler upon startup of the application so that it
instantiates the Editor component correctly.
Lastly, modify the UI so that it is easier to work within the application.
Additional Resources
If you are interested in learning more on editing web applications using the Flex API, see
the Editing topic where much of the information above is provided in greater detail.
Additional information
Version 3.7
Note:
The following steps assume you have completed the steps necessary to create a new project and
add the Flex API library as discussed in the Getting started topic.
1. In Flash Builder, create a new project and make certain to add the Flex API library and reference
the esri namespace.
2. In the Editor View, add the MXML below to create a map with a set spatial reference and extent
and add a basemap layer
Copyright 2016 Esri. All rights reserved.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags">
<esri:Map id="map">
<esri:extent>
<esri:WebMercatorExtent xmin="-20119163" ymin="1160734" xmax="-1333999" ymax="10416341"/>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer/>
</esri:Map>
</s:Application>
Note:
No Geocoder URL is set as it defaults to the ArcGIS Online World Geocoding Service. This can
be set to work with another defined geocoding service, or layers within a map service. If using
your own geocode locator service, it will need to be configured to use single line style similar to
how the default locator service is configured.
...
<esri:ArcGISTiledMapServiceLayer/>
</esri:Map>
<esri:Geocoder
width="300"
height="30"
top="20"
horizontalCenter="0"
map="{map}"/>
</s:Application>
You should see something similar to what is displayed in the screen capture below.
Finding places and addresses does not require a lot of coding when working with the provided
Geocoding component. This component bundles a lot of the functionality within it so all you
need to do is reference it in your code. We were able to determine a provided place name in just
a few steps. Conceptually, this is how the code breaks down:
Additional information
If you are interested in reading more about finding place and address functionality, please see
the Geocoder topic.
Version 3.7
next to the map and (optionally) specify your own network analysis service instead of the default
routing service.
Prerequisites
Note:
The following steps assume you have completed the steps necessary to create a new project and
add the Flex API library as discussed in the Getting started topic.
1. In Flash Builder, create a new project and make certain to add the Flex API library and reference
the esri namespace.
2. In the Editor View, add the MXML below to create a map with a set spatial reference and extent
and add a basemap layer
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags">
<esri:Map id="map">
<esri:extent>
<esri:WebMercatorExtent xmin="-13055785" ymin="3848161" xmax="-13025898"
ymax="3866239" spatialReference="{new SpatialReference(102100)}"/>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer/>
</esri:Map>
</s:Application>
Note:
The above markup sets the padding on the left-hand side as to allow the directions component to
display next to the map.
28. Next, add the Directions component.
Note:
The Network Analyst service URL is referencing a sample from ArcGIS Online. This is limited
to San Diego's extent. If you wish to work outside of this area, you will need to either: 1) access
an ArcGIS.com subscription with World Network Analysis, or 2) use your own ArcGIS Server
Network Analysis service.
...
<s:layout>
<s:HorizontalLayout paddingLeft="2"/>
</s:layout>
<esri:Directions width="320" height="100%"
map="{map}"
url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Ro
ute"/>
<esri:Map id="map">
<esri:extent>
...
Calculate the driving directions after entering the destinations. You should see something similar
to what is displayed in the screen capture below.
Calculating directions does not require a lot of coding when working with the provided
Directions component. This component bundles a lot of the functionality within it so all you need
to do is reference it in your code. We calculated simple driving directions in just a few steps.
Conceptually, this is how the code breaks down:
Create a map
In this topic
Map overview
Additional references
Version 3.7
Map overview
There are a couple of different ways to work with maps in the Flex API. The first is to add
various layers (services) to the map. These layers can originate from ArcGIS for Server, Bing
Maps, graphics layers, etc. The other option is to work with web maps shared from a portal such
as ArcGIS.com or one hosted on-premise. Web maps provide similar functionality as they can
contain various layer types, tasks, and data from an external source, (e.g. .csv files and .gpx files
to name a couple). The main difference is that all of this is bundled up within the web map itself.
We will discuss these two options in a bit more detail below.
After the map is set, you can also apply an extent and spatial reference to it. The extent of all the
layers in a map service is what is used to determine the map extent provided by this service. This
is important when determining the initial extent displayed in a web application. By default, the
initial extent is determined by the first layer in the map's layer collection, generally referred to as
the basemap. If you do not wish to use this initial default extent, you can modify it by setting it
using Extent .
Set the map and extent
...
<fx:Declarations>
<esri:Extent id="initialExtent"
xmin="-17731" ymin="6710077" xmax="-12495" ymax="6712279">
</esri:Extent>
</fx:Declarations>
<esri:Map extent="{initialExtent}">
</esri:Map>
Note:
More information regarding working with extent can be found at Using Extent.
Spatial reference
Every map service has a spatial reference. This spatial reference can be either set as unprojected
(Geographic) or projected (e.g. UTM, Web Mercator, etc.). There are many coordinate systems
used throughout the world today, depending on which part of the earth being mapped. A very
common one used throughout web mapping applications is Web Mercator (Auxillary Sphere).
This coordinate system is used by Bing Maps, Google Maps, and Esri's ArcGIS Online. A listing
of of WKIDs and their corresponding coordinate system is provided at Coordinate system IDs.
Similar to how the extent gets set by the first layer in the map's layer collection, the spatial
reference of the map is set by the first layer in the layer collection. Alternatively, you could
change this by setting the spatial reference using SpatialReference .
Set the map, its extent and spatial reference, and add a tiled layer.
...
<fx:Declarations>
<esri:Extent id="initialExtent"
xmin="-17731" ymin="6710077" xmax="-12495" ymax="6712279">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</fx:Declarations>
<esri:Map extent="{initialExtent}">
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</esri:Map>
...
Note:
Tiled layers such as ArcGISTiledMapServiceLayers , must support the spatial reference of the
map. They cannot be reprojected to another spatial reference like dynamic map service
layers, ArcGISDynamicMapServiceLayers .
This snippet of code would display a tiled layer in your map with its initial extent centered on
London as seen below.
Similar to setting the extent of the map, you can also zoom to a specified level and center on a
given lat/lon point. The level refers to the level of detail (LOD) ID for the map. This is only valid
if the map has LODs. For example, the cached World Street map
service, http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer
, has 20 LODs. You can reference this by browsing to its service directory and taking note of
the Tile Info provided. The following code snippet references this service and zooms to level
15. It also centers the map on the provided point specified via its lat/lon coordinates.
The code snippet above would display similar as the snippet using Extent . Each of these
displaying a map centered on London.
In the screen capture above, the URL address for the web map is . The item ID is the web map
value, e.g. 2f1d4a31078d460aa4a7aa46f5b882e5.
Snippet showing how to add a web map to a Flex API application
Additional references
Learn more about the web map format
Learn more about working with web maps
Tutorial: Adding a map with layers
Tutorial: Add a web map to the application
Using Extent
In this topic
Tutorial overview
Setting an extent
Version 3.7
Tutorial overview
Note:
The discussion in this topic assumes that you are familiar with the basic concepts of Flex.
This tutorial describes several ways to set the extent of the map as well as how to retrieve the
extent for use in other operations.
If you don't include extent information when you initialize a map, the default extent is used,
which is the extent of the map as it was last saved in the map document. If you use multiple
layers, or services, the default extent is the initial extent of the basemap or first layer added.
Setting an extent
Copyright 2016 Esri. All rights reserved.
To set an initial extent that is different from the default extent, use the extent property or Extent
class.
Using the extent property
To set the map extent using the extent property, perform the following steps:
1. Add your map.
2. Insert the <esri:Extent> tag and specify the ID and coordinates.
3. Add the <esri:ArcGISDynamicMapServiceLayer> tag.
To set the initial map extent using the Extent class, perform the following steps:
1.
2.
3.
4.
In some cases, you may want to use the extent of a layer that is not the initial layer or basemap.
To do this, set the map extent to the extent of the desired layer. In the following example, two
layers are used: the base layer (ArcGIS Online world extent) and a second layer (the state of
Kansas).
To set Kansas as the extent, add a load property that sets the extent of the map:
load="myMap.extent = myKansasLayer.fullExtent"
The load property creates the map and, when loaded, sets the full extent to the Kansas layer.
The following code sets the map extent to myKansasLayer using fullExtent :
<esri:Map id="myMap">
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/
ESRI_StreetMap_World_2D/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer
load="myMap.extent = myKansasLayer.fullExtent"
id="myKansasLayer"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/
Petroleum/KGS_OilGasFields_Kansas/MapServer" />
</esri:Map>
Tip:
To set the initial extent instead of the full extent, use myKansasLayer.initialExtent .
MXML example:
ActionScript example:
Time-aware layers
In this topic
Samples
Version 3.7
ArcGIS 10 includes support for time-aware layers, which store information about the changing
state of a dataset over time. Time-aware layers allow you to step through periods of time
revealing patterns and trends in your data. For example, you can do the following:
The time extent of the map defines the time period for the data that is displayed by the timeaware layers. Setting the map's time extent is similar to setting the spatial extent, because once
the time extent is set, the map display updates automatically to conform to the change. Every
time the map's time extent is changed, all time-aware layers update to reflect the new time extent.
There are several ways to work with time-aware layers in a web API-based application. The
simplest is to use the TimeSlider component because it handles the process of updating the map's
time extent for you. You can also build applications that perform temporal queries, filter layers
using time definitions, and set the map's time extent.
When working with time-aware layers, you may need to create dates to define a time extent. The
server assumes times sent in are in Coordinated Universal Time (UTC), so you should create
dates with that in mind. UTC is a time standard based on atomic time and is functionally
equivalent to Greenwich Mean Time (GMT).
// UTC
var decemberTimeExtent:TimeExtent = new TimeExtent
(new Date("2009/01/01 00:00:00 UTC"),new Date("2009/01/31 23:59:59 UTC"));
// Local Time
var decemberLocalTimeExtent:TimeExtent = new TimeExtent
(new Date("2009/01/01 00:00:00"),new Date("2009/01/31 23:59:59"));
Slider 'thumbs' denote a location on the slider. Possible values are '1' and '2'. The previous code
has the thumb count set to 1; this means that the map will display all features from the first time
to the current thumb position. To visualize a time range, set the thumb count to 2. To visualize
features for an instant in time, set the thumb count to 1 and set createTimeInstant=true .
Note:
It is not recommended to use the time slider with feature layers in on demand mode because this
can result in too many requests to the server. If you are not working with a large amount of data,
you can use a feature layer in snapshot mode. If your dataset is large, consider using an
ArcGISDynamicMapServiceLayer instead.
Filtering data using the map's timeExtent property
There are other ways besides the TimeSlider to visualize time-aware layers in your mapping
applications. The map has a timeExtent property that acts as a filter for layers that support time,
such as the ArcGISDynamicMapServiceLayer and FeatureLayer. Setting the map's time extent
fires the timeExtentChange event. Time-aware layers listen for this event and update themselves
to display content for the specified time extent. In the following example, only data that meets
the input time definition of December 31, 2010 appears:
var ti:TimeExtent = new TimeExtent();
ti.startTime = new Date("12/31/2010 UTC");
myMap.timeExtent = ti;
Filtering data using the layer's time definition using snapshot mode
Feature layers support the ability to set a time definition, which limits the data that is loaded in
the initial query. Setting a time definition on a layer is similar to setting a definition expression
and restricts the data to only features that match the input time extent. When you set a time
definition on a feature layer in snapshot mode, the features that match the time definition are
retrieved once the layer is loaded. If you modify the time definition after the layer is loaded, the
existing set of features is destroyed and a new request is made to retrieve the new set of features.
The current selection is always maintained and will not be destroyed if you set a new time
definition.
var myTimeDef:TimeExtent = new TimeExtent();
myTimeDef.startTime = new Date("2003/09/25 UTC");
myTimeDef.endTime = new Date("2005/10/25 UTC");
myFeatureLayer.timeDefinition = myTimeDef;
You can perform temporal queries against time-aware layers using the timeExtent property on
the Query object. For example, you might want to know all crimes that occurred during the night
shift from 10 p.m. to 6 a.m. on a particular date:
var ti:TimeExtent = new TimeExtent();
ti.startTime = new Date("06/13/2012 22:00:00");
ti.endTime = new Date("06/14/2012 06:00:00");
var myQuery:Query = new Query();
myQuery.timeExtent = ti;
myFeatureLayer.queryFeatures(myQuery);
Samples
The ArcGIS API for Flex has several samples that show how to work with time-aware layers
including the following:
Layers overview
In this topic
Version 3.7
ArcGISTiledMapServiceLayer
OpenStreetMapLayer
WMTSLayer
VETiledLayer
ArcGISLocalTiledLayer
WebTiledLayer
ArcGISDynamicMapServiceLayer
ArcGISImageServiceLayer
GPResultImageLayer
WMSLayer
ArcIMSMapServiceLayer
GraphicsLayer
FeatureLayer
CSVLayer
GeoRSSLayer
KMLLayer
MapImageLayer
Basemap layers
In this topic
Additional Resources
Version 3.7
ArcGISTiledMapServiceLayer
OpenStreetMapLayer
WMTSLayer
VETiledLayer
ArcGISLocalTiledLayer
Note:
Basemaps tend to be relatively static and are typically updated on an infrequent basis. Generally,
you use basemap layers as the framework for which you display dynamic operational and/or
graphics layers. For more information regarding working with basemaps, see Working with
basemap layers
Note:
Of the basemap layer types listed above, the ArcGISTiledMapServiceLayer andWMTSLayer classes
use a cached map service hosted from ArcGIS for Server.
Additional Resources
Please refer to the various samples illustrating how to use these various types of layers. You can
download these samples from GitHub.
Operational layers
In this topic
Version 3.7
ArcGIS for Server hosts both cached and dynamic data. The operational layers, or dynamic
layers, inherit directly from the DynamicMapServiceLayer class, which in turn, extends
the Layer class. These types are:
ArcGISDynamicMapServiceLayer
ArcGISImageServiceLayer, for more information, see Key concepts for Image Services
GPResultImageLayer
WMSLayer, for more information, see WMS Services
ArcIMSMapServiceLayer
Client-side graphics
Client-side graphics allows information to be displayed more efficiently on the client machine.
This is typically done in use cases that involve graphics as user input for markup or a task, or the
graphics can be drawn as an output response from a task. The client-side graphics layer types
include:
GraphicsLayer, for more information regarding working with graphics and the GraphicsLayer ,
see Using Graphics
FeatureLayer, this layer extends GraphicsLayer . For more information regarding working with
feature layers, see Feature Layer
CSVLayer, this layer extends FeatureLayer. For more information regarding working with
the CSVLayer , see CSVLayer
GeoRSSLayer, this layer extends directly from the Layer class and is used to create a layer based
on GeoRSS. GeoRSS is a way to add geographic information to an RSS feed
KMLLayer, this layer extends directly from the Layer class and is used to create a layer based on
publicly accessible KML or KMZ files. For more information regarding working with KML data,
please see KML support in ArcGIS Server.
In addition to the layer types listed above, there is an additional MapImageLayer type. This
directly inherits off of Layer and is used to add georeferenced images to the map. It is used to
work with dynamically generated Map Image objects. A MapImage is accessed a couple of
different ways:
GroundOverlays - come back as part of KML. Every ground overlay is treated as a map image
where MapImage.source is the URL to the image.
Geoprocessing operations - The export operation on ArcGISDynamicMapServiceLayer returns
a MapImage in addition to GeoProcessor.getResultImage .
Using Graphics
In this topic
Version 3.7
The following discussion assumes that you are familiar with the basic concepts of Flex.
Working with graphics
When the ArcGIS API for Flex was first released, the only option for displaying information
client-side was through the use of a graphics layer. The graphics layer allows you to dynamically
display graphics on a map. The graphics can be drawn by the user as markup or input to a task,
or they can be drawn by the application in response to a task. For example, the application might
add the results of a query to the map as graphics.
A graphic is composed of the following:
Geometry The geometry determines where the graphic is located. IT can be point, multipoint,
polyline, polygon, or extent.
Symbol The symbol determines how the graphic looks. It can be a marker symbol (for point
and multipoint geometries), a line symbol (for polylines), or a fill symbol (for polygons). For
more information on working with symbols in graphics, see Symbols and Renderers.
Attributes These are name-value pairs that describe the graphic. If you create the graphic,
you need to assign the attributes. If the graphic is created in response to a task performed on a
Graphics are not required to have all of three items as listed above. For example, many task
results are returned as graphic objects in a FeatureSet. These graphics have only geometry and
attributes when they are returned. If you want to add the graphics to a map, you must define a
symbol for them.
If you're writing code that allows users to draw graphics on the map, the Draw tool can make
your work easier. DrawTool is a class that can help you capture the geometry that a user draws
on the screen. You can then define a symbol and apply it to the geometry in a new graphic
object. The DrawTool sample demonstrates this workflow.
The way that you add task results to the map as graphics varies by task type. If your task returns
a feature set, you get an array of graphics (FeatureSet.features) that you can assign to
graphicProvider of GraphicsLayer. The code below shows how you might do this with results
from QueryTask.
This code defines a symbol to the graphics layer that is assigned to all the graphics added to that
layer.
private function doQuery():void
{
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
myGraphicsLayer.graphicProvider = featureSet.features;
}
function onFault(info:Object, token:Object = null):void
{
Alert.show( info.toString() );
}
}
<esri:SimpleMarkerSymbol id="sms" size="10" color="0xFF0000" style="circle" />
<esri:GraphicsLayer id="myGraphicsLayer" symbol="{sms}"/>
Other tasks do not provide a feature set as a result but do provide the geometry, which you can
use to create a graphic. For example, a Locator task finds an address candidate, whose location
property is a MapPoint geometry. You can use this geometry to create a graphic showing the
address location, as in the code below:
for each (var candidate:AddressCandidate in candidates)
{
if (candidate.score > 80) {
var myGraphic:Graphic = new Graphic();
myGraphic.geometry = candidate.location;
myGraphic.symbol = mySymbol;
myGraphic.attributes = { address: candidate.address,score: candidate.score, locatorName:
candidate.attributes.Loc_name };
myGraphicsLayer.add(myGraphic);
}
}
See the samples for more ideas of how to create graphics from the results of different tasks.
3.0 and above
Starting with version 3.0 of the ArcGIS API for Flex, a defaultGraphicsLayer property was
added to the Map class. This references the default graphics layer that is always displayed on top
of all other layers in the map. This graphics layer cannot be removed.
Extending the graphics layer
The graphics layer is a very useful class that provides vast functionality. You can add to the
already existing functionality provided by the graphics layer by extending it to build your own
custom graphics layer. One example as to why you may want to create an extendable version of
the graphics layer would be if you have attribute information that should correspond to a specific
level of geography, e.g. census data in relation to county polygons. A custom graphics layer
could be created that uses the geometry from an ArcGIS for Server service and corresponding
attribute information could be derived from another back-end service, combining them to create
graphic objects within a custom graphics layer. The FeatureLayer class was introduced at version
2.0 of the ArcGIS API for Flex and is a prime example of extending the GraphisLayer class.
Conceptual overview of working with Graphics
The following provides high-level steps of working with graphics in the API:
1.
2.
3.
4.
5.
Feature layer
In this topic
Samples
Version 3.7
Feature layers are used to display features from one single layer of either a
feature or map service. The layer can be either a spatial layer or non-spatial
table. The ArcGIS API for Flex version 2.0 and above offers a FeatureLayer for
working with client-side graphic features. You may be familiar with
the GraphicsLayer from previous releases. The feature layer inherits from the
graphics layer and offers additional capabilities such as the ability to perform
queries and selections. Feature layers are also used for web editing if based on a
layer in a feature service.
Feature layers differ from tiled and dynamic map service layers because they
bring geometry information across to the client computer to be drawn by the
client. Feature layers potentially cut down on round-trips to the server. A client
can request the features it needs, then perform selections and queries on those
features without having to request more information from the server. Feature
layers are especially appropriate for layers that respond to user interaction, such
as a mouse click or hover.
A feature layer honors any definition queries, scale dependencies, and other
properties configured on the layer in the map service. Using a feature layer, you
can access related tables, perform queries, display periods of time, and work
with feature attachments.
When you create a feature service, you also need to specify one of these modes for retrieving
features:
On demand mode (the default) retrieves features as they are needed, requesting only the
features within your current view extent. On demand mode potentially requires more round
trips between the client and server. However, it protects you from retrieving more features than
you need.
Snapshot mode retrieves all the features from the layer immediately after the layer is added to
the map. This reduces subsequent traffic to the server, but can become cumbersome if the layer
contains many features. The browser may be overwhelmed by the number of features it needs
to draw, or the service may reach its limit of how many features it can return at once. The
default is 500 for ArcGIS 9.3.1 and 1,000 for ArcGIS 10.x.
Use snapshot mode primarily with smaller datasets or with temporal data.
Selection mode does not initially request any features. Features are added only when a selection
is made. This mode is useful when you cannot or do not want to bring all features into the client,
but you want to highlight one or more features for a certain reason, for example, editing,
querying, or accessing related tables. Selections are drawn using a client-side selection color
that you specify on the feature layer.
Query: you can use a dynamic service for your general map representation, but when doing an
identify or query you want to highlight the selected features.
Editing: only the selected feature will be highlighted on the map within the feature layer.
Once editing is complete, the selection is removed from the feature layer and the user can
update the dynamic map service layer to see the updated feature.
Tip:
No matter which of the display modes you choose for your feature layer, selected features are
always held on the client. For example, if you are using the on demand display mode and you
have selected some features, panning away from those selected features will still result in the
features being available on the client. Your application will not have to reselect the features or
make any other request to the server if you pan back to the original area. For this reason, it is a
good practice to clear your selected features once they are no longer needed.
Choosing the attributes you need
Feature layers retrieve both feature geometries and attribute information. When you create the
feature layer, you can set the outFields property to specify which attributes will be retrieved for
your features. It is possible to use the asterisk (*) to get all the fields, but to reduce the amount of
information sent between the client and server, you should request only the fields you need in
your application. If you later perform a query using the feature layer, the query will honor the
outfields you set.
Feature layers are the key to editing features with the web APIs. The editing components
included in the APIs are designed to work with feature layers. You can only perform editing on
feature layers that reference an editable layer within a feature service. See Editing to learn more
about this requirement and how to create a feature service.
There may be times where you want to work with features that satisfy certain attribute criteria
and disregard the rest. In this type of situation, you can set a definition expression on the feature
layer to retrieve just the features you need. Every feature layer has
a definitionExpression property, which comes from the definition query set in the source map
document.
Time
When using a feature layer in snapshot mode, you can retrieve features that meet a certain
temporal criteria using the timeDefinition property on the feature layer. This property
temporarilty defines the features in the layer to match a specified TimeExtent. This option is only
available with features loaded in snapshot mode. For example, you might want to only load
houses that were built before 1930. You would set the feature layer's timeDefinition to a
TimeExtent prior to 1930.
Note:
The feature layer supports a selection, which represents a subset of features that the user has
chosen to isolate for viewing, editing, or analytical purposes. Users can add or remove features
from the selection based on spatial or attribute criteria. The feature layer makes it easy to draw
the selection set with a different type of symbol than the other features. If you don't specify the
symbol, a default symbol will be applied. This was previously challenging to do without using
two graphics layers.
A selection set can be used as input for statistical calculations, geoprocessing tools, and
graphing. Therefore, opening the possibility for interactive GIS analysis and exploration. For
example, users can draw a polygon to select a set of buildings, then push a button to calculate the
solar potential of those buildings. Selections also play an important role in some editing
workflows where the feature currently undergoing edits is highlighted.
To make your selection, use the selectFeatures method on feature layer which takes a query
object as an argument. If you are interested in querying your feature layer without adding the
results to the selection set, you can use either queryFeatures orqueryRelatedFeatures instead.
With any of these methods, you cannot request features outside of any definition expressions set
in the map document or on the feature layer.
Samples
The ArcGIS API for Flex has several samples that show how to work with feature layers. Here
are a few you may find useful:
AttributeTable
In this topic
Conceptual workflow
Additional references
Version 3.7
The AttributeTable component displays a tabular view of a feature layer's
attributes. If the feature layer is editable, you can edit the records within the table
widget as well. It recognizes layers added specifically as feature layers, whether
it be from a Feature Service or Dynamic Map Service. In addition to feature
layers that are directly added, it will also recognize any layers within a full
dynamic map service as well and display features within the extent.
Export the attributes to a CSV fileExports the attributes to a separate CSV file.
Note:
If records are selected, only the selected features are written to this file. If working with
point feature classes, two additional fields are also written into this CSV file indicating
latitude and longitude. This specific feature with points is only supported for Web
Mercator and Geographic spatial references.
Show attachmentsThis option is available if the feature layer has attachments enabled on it.
Show related recordsThis option is available if the feature layer has any associated
relationships.
Note:
If a Uniform Resource Locator (URL) exists as a field value in your service it will display as a
text string in the attribute table and not as a hyperlink.
If you are outside an extent and are not displaying any visible features, a message will appear
displaying "No features in current map extent". Also, if your scale is out of the visible range of
the layer, you will receive a message stating "Layer is out of scale range".
Conceptual workflow
Requires: Feature layers from either a dynamic map service or feature service.
Reads feature layers and populates the contents of the widget with the corresponding feature's
records within the current map extent. If more than one layer, multiple tabs will display in the
table.
Attribute table updates as feature(s) updates change with extent changes.
Interactive functionality between records and features in the map.
Edits can be performed on the records if the layer is editable.
Additional references
To test out this functionality, see the AttributeTable sample.
Symbols
Renderers
Version 3.7
Symbols
Symbols define the non-geographic aspects of a graphic's appearance, including color, border
width, transparency, and so on. The ArcGIS API for Flex includes many symbol classes, each of
which allows you to specify symbology in a unique way. Each symbol type is also specific to
one geometry type (that is, point, line, or polygon).
The following table lists the different types of symbols available with the ArcGIS API for Flex.
Type
Description
PictureMarkerSymbol
Symbolizes points with images
SimpleMarkerSymbol
Symbolizes points with simple shapes
SimpleLineSymbol andCartographicLineSymbol Symbolizes lines with pre-defined styles
SimpleFillSymbol
Symbolizes polygons with a specified fill style
PictureFillSymbol
Symbolizes polygons with an image
TextSymbol
Symbolizes text at points on a graphics layer
CompositeSymbol
Symbolizes multiple symbols on a single graphic
Symbolizes point data with small window showing UI
InfoSymbol
control and data. For more information, see the
topic InfoSymbol and InfoRenderer.
The symbol of a graphic can be determined in the following ways:
Renderers
A renderer defines a set of symbols that will be used for graphics in a graphics layer. You can
use renderers to symbolize features with different colors or sizes based on a particular field
attribute.
There are four types of renderers provided with the ArcGIS API for Flex. All of these renderer
classes reside in the com.esri.ags.renderers package.
Simple Renderer
Class Breaks Renderer
Unique Value Renderer
Temporal Renderer
Tip:
While it is possible to have different geometries (for example, points and lines in the same
graphics layer), renderers work best when the layer has only one type of geometry.
A simple renderer uses the same symbol for every graphic. All you do is specify the symbol to
be used by the renderer, then apply the renderer to the graphics layer. This is equivalent to
setting the symbol on the graphics layer.
<esri:GraphicsLayer id="graphicsLayer">
<esri:renderer>
<esri:SimpleRenderer symbol="{smallSym}"/>
</esri:renderer>
</esri:GraphicsLayer>
or
<esri:GraphicsLayer id="graphicsLayer" symbol="{smallSym}"/>
A class breaks renderer symbolizes each graphic based on the value of one of its fields. Graphics
with field values inside the class break (a.k.a. range) will all use the same symbol. The breaks
define the values at which the symbology changes. For example, suppose you have a 'buildings'
layer with a field that defines the building's age. You want to symbolize buildings constructed
since the year 2000 in green, buildings constructed between 1980 and 2000 in yellow, and
buildings built before 1980 with red. This would be a good scenario for a class breaks renderer.
To use a class breaks renderer, you simply add one or more breaks. Each break specifies the
symbol to use and the minimum and maximum values that will be used for that symbol. The
following code example shows how you can explicitly define the breaks.
var smallSym:SimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,6,
0xFF0000, 0.7);
var mediumSym:SimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,10,
0xFF0000, 0.7);
var largeSym:SimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,16,
0xFF0000, 0.7);
var classBreaksRenderer:ClassBreaksRenderer = new ClassBreaksRenderer();
classBreaksRenderer.field = "BUILD_DATE";
var classBreakInfos:Array = [
new ClassBreakInfo(smallSym, Number.NEGATIVE_INFINITY, 1980),
new ClassBreakInfo(mediumSym, 1980, 2000),
new ClassBreakInfo(largeSym, 2000, Number.POSITIVE_INFINITY)
];
classBreaksRenderer.infos = classBreakInfos;
graphicsLayer.renderer = classBreaksRenderer;
Note:
If there is no maximum limit on a break, you can use "Number.POSITIVE_INFINITY for the
maximum value. Similarly, you can use Number.NEGATIVE_INFINITY when there is no minimum.
Any value that is greater than or equal to the minimum will be included in the break. Any value
that is less than the maximum will be included in the break. Consequently, if you have two
breaks, 010 and 1020, the value 10 would fall in the second break (1020). Avoid creating
Copyright 2016 Esri. All rights reserved.
overlapping breaks or gaps between breaks. You can also define breaks mathematically. For
example, you can do some basic arithmetic to ensure that each break falls an equal distance apart
given the input data (sometimes known as an equal interval classification).
var numRanges : int = 10;
var breaks:Number = (max - min) / numRanges;
for (var i:int = 0; i < numRanges; i++)
{
classBreakInfos.push(new ClassBreakInfo(
new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, (i+1)*5, 0xFF0000, 0.7),
min + (i*breaks),
min + ((i+1)*breaks)
)
);
}
A unique value renderer symbolizes groups of graphics that have matching fields. For example,
you can use a unique value renderer to symbolize zoning designations: red for Residential, green
for Industrial, blue for Commercial, and so on. To define a unique value renderer, you specify
the field on which to base it, and an optional defaultSymbol for values that are not covered by a
specific UniqueValueInfo. Each UniqueValueInfo contains the specific value and symbol to use
for each unique value.
<esri:SimpleFillSymbol id="rFill" alpha="0.5" color="0xFF0000"/>
<esri:SimpleFillSymbol id="gFill" alpha="0.5" color="0x00FF00"/>
<esri:SimpleFillSymbol id="bFill" alpha="0.5" color="0x0000FF"/>
<esri:UniqueValueRenderer id="uniqueValueRenderer" field="ZONING">
<esri:UniqueValueInfo value="Residential" symbol="{rFill}"/>
<esri:UniqueValueInfo value="Industrial" symbol="{gFill}"/>
<esri:UniqueValueInfo value="Commercial" symbol="{bFill}"/>
</esri:UniqueValueRenderer>
Values that aren't added to the list are not drawn unless you specify a defaultSymbol on the
UniqueValueRenderer, in which case those graphics are drawn with the default symbol.
Temporal renderer
Note:
This section specifically discusses temporal rendering. For more information regarding working
with time data, see Time-aware layers.
A temporal renderer is a custom renderer where the symbology of a FeatureLayer is displayed
based upon the featurelayer's time field. Temporal renderers are useful when visualizing historic
or real-time data such as hurricanes or earthquake occurrences.
The observationRenderer property provides a default set of symbology for features in a timebased layer. This default symbology can be overridden by thelatestObservationRenderer and
the trackRenderer to provide additional ways to graphically represent the features that are
returned from a featurelayer. While it is theoretically possible to have any renderer that
implements the IRenderer interface be used as the observationRenderer property, it typically
makes sense to only use a SimpleRenderer, ClassBreaksRenderer, or UniqueValueRenderer.
The latestObservationRenderer property provides a default set of symbology for the last timebased feature returned per the featurelayer's time field. If no time field has been specified than
just the last observation that is returned from the featurelayer will be symbolized. Whatever
symbology properties that have been set (for example: a symbols color, size, and style) for
the latestObservationRenderer will override what was set for the observationRenderer. While it
is theoretically possible to have any renderer that implements the IRenderer interface be used as
the latestObservationRendererproperty, it typically makes sense to only use a SimpleRenderer,
ClassBreaksRenderer, or UniqueValueRenderer.
The trackRenderer property provides polyline based symbology that connects markers (i.e.
points) for time-based features per the feature layer's time field. If no time field has been
specified than all observations that are returned from the feature layer will be symbolized in
sequential order using the polyline graphic. The polyline graphic that is drawn begins with the
first temporal observation and connects-the-dots as the phenomena moves spatially through time.
The observationAger property is an optional technique to modify a symbols size, color, and
opacity for the renderers applied to the TemporalRenderer as a features time stamp adjusts. Two
observationAgers are supported: the TimeRampAger andTimeClassBreaksAger.
The TimeRampAger will modify the rendering of entire set of features and graduate the
symbology based upon the set properties (except for thelatestObservationRenderer).
The TimeClassBreaksAger will modify the rendering of a specific set of defined groups based
upon a range of values. If a specific group has not been defined by
the TimeClassBreaksAger than the observationRenderer will take precedence; additionally
the latestObservationRenderer takes precedence if set.
To see a working sample that uses a temporal renderer with a TimeRampAger,
seeTime_rendered_5K_run_(gpx).
Limitations
Version 3.7
You can define infoRenderer as inline (in other words, defined in the same file as InfoSymbol).
To define an inline infoRenderer, do the following:
1. Insert InfoSymbol and infoRenderer tags.
2. Define UI controls within the <fx:Component> tag. These will be the contents of InfoSymbol .
3. If necessary, use outerDocument to include variables and methods outside <fx:Component> .
<esri:InfoSymbol id="infoSymbol1">
<esri:infoRenderer>
<fx:Component>
<mx:VBox>
<mx:Panel id="myPanel" height="100%"
width="100%" backgroundAlpha="0"
initialize="{outerDocument.initPanel(event)}"/>
<mx:Button id="myButton" height="100%"
width="100%"
click="{outerDocument.showResults()}"/>
</mx:VBox>
</fx:Component>
</esri:infoRenderer>
</esri:InfoSymbol>
Defined in a separate file from InfoSymbol, external infoRenderers are preferred because of their
modular, reusable design. The external infoRenderer is defined by taking all the content that
would be contained between the <fx:Component> tags and placing it in a discrete MXML or
ActionScript file. An example of an infoRenderer in a separate MXML file called
MyInfoRenderer.mxml will look like below:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:fx="http://ns.adobe.com/mxml/2009"
backgroundColor="0xEEEEEE"
label="{data.STATE_NAME}"
>
<mx:Label text="State Fips: {data.STATE_FIPS}"/>
<mx:Label text="Abbreviation: {data.STATE_ABBR}"/>
<mx:Label text="Area: {data.AREA}"/>
</mx:VBox>
Once defined, the infoRenderer can be used by any InfoSymbol in ActionScript or MXML. To
set the infoRenderer in ActionScript, construct your code similarly to the following:
var mySymbol:InfoSymbol = new InfoSymbol();
mySymbol.infoRenderer = new ClassFactory(MyInfoRenderer);
myGraphic.symbol = mySymbol;
To set the infoRenderer in MXML, construct your code similarly to the following:
<esri:InfoSymbol id="infoSymbol1" infoRenderer="MyInfoRenderer"/>
Limitations
InfoSymbol can only be assigned to points. To add InfoSymbols to multipoints, convert them to
points. To add InfoSymbols to lines or polygons, you can find a label point of the line or polygon
and either change the graphic's geometry to center point or create a new point graphic at the
location of the center point.
For example:
var polygon: Polygon;
var centerPt: MapPoint;
polygon = myGraphic.geometry as Polygon;
centerPt = polygon.extent.center;
myGraphic.geometry = centerPt;
Additional Resources
Version 3.7
Dynamic layers allow clients to change layer appearance and behavior on-the-fly in a map
service. A dynamic layer / table resource represents a single layer / table of a map service
published by ArcGIS Server or of a registered dynamic workspace. Dynamic layers supports
adding feature layers and raster layers from the following data sources:
Enterprise geodatabase
File geodatabase
Shapefile
File-based raster
Query layers - from and ArcSDE enterprise geodatabase or non-SDE enterprise database.
If you are uncertain whether your dynamic map service supports dynamic layers, you can check
its metadata directly in the REST services directory. There is a parameter called Supported
Dynamic Layers and will report as either true or false depending on how the service was
initially configured.
Besides manually checking the REST services directory to verify if it supports this functionality,
the ArcGISDynamicMapServiceLayer's supportsDynamicLayers property also indicates whether
this functionality has been set.
See Enabling dynamic layers on a map service in ArcGIS Desktop and Enabling dynamic layers
on a map service in Manager for additional information on this setting.
Common dynamic workflow scenarios
The following describes some common reasons you may want to dynamically alter your map
service:
Define whether labels will appear for a layer. See the samples, LabelOptionsWizard,Dynamic
labeling, and Dynamic labeling (advanced).
Define layer symbology. See the samples, Change LayerDrawingOptions, Generate
renderers, RangeValueRenderer, and UniqueValueRenderer.
Define how layers are rendered (simple, unique value, or class breaks). See the samples, Change
LayerDrawingOptions, Generate renderers, RangeValueRenderer, and UniqueValueRenderer.
Define the position and order of layers in the map service. See the sample, Change Layer
Ordering.
Add new layers to the service from a registered workspace. See the sample, Dynamic
workspace.
Modify and/or add joins to an existing or new layer/table. See the sample,DynamicLayerInfo
JoinDataSource.
Additional Resources
Please see Dynamic Workspaces and Dynamic Rendering for additional information regarding
dynamically altering map services.
Dynamic Workspaces
In this topic
Dynamic workspaces
Additional Resources
Version 3.7
Dynamic workspaces
If you want to dynamically add data to your map service, such as feature classes, shapefiles,
rasters, or feature attribute tables, you will need to set up a workspace to contain the data you
want to add. Dynamic workspaces can be any enterprise geodatabase, file geodatabase, or file
directory on disk that is accessible to the server. If your dynamic workspace is an enterprise
geodatabase, you have the option of limiting user access to the geodatabase by locking the
database version.
Let's discuss why the ability to dynamically add data to a map service is so useful. First consider
that, for performance reasons, it is generally good practice to keep the number of layers in a
dynamic map service to a minimum. With this said, there may be circumstances when a use-case
may warrant the ability to work with multiple layers in a map service. This would be a good
opportunity to take advantage of dynamic workspaces and their ability to add data to the map
service on-the-fly.
For example, consider you have a service with basic layers such as states, provinces, counties,
rivers, and/or cities. These are used as template base layers for your service. You may have
requirements that call for adding potentially hundreds of various layers to the template base
layers. Prior to ArcGIS 10.1, you would have had to put all of these layers in the source
document that was used to create the service. Now all you need to do is make certain that the
service allows dynamic capability with per-request modification of layer order and symbology.
Copyright 2016 Esri. All rights reserved.
You can then add data, as in the above example where the 'hundreds of layers', would reside in
this registered workspace. When you add a dynamic workspace, you provide the workspace type,
id, and location. Once you have configured these settings, you then have the capability to add
data from the registered location to your map service dynamically. See the ArcGIS Help for
more information on how to do configure these settings.
Dynamically adding layers at runtime
The Dynamic workspace sample illustrates how to dynamically add a layer at runtime. This
sample uses the ArcGISDynamicMapServiceLayer's layerDrawingOptions property in addition
to its createDynamicLayerInfosFromLayerInfos method. This method returns an array
of DynamicLayerInfo instances. The sample gets the dynamic layer info array from the dynamic
map service, it then writes back to this array with a new DynamicLayerInfo object. After this, the
layerDrawingOptions property is written to that of a new layerDrawingOptions instance.
Snippet taken from Dynamic workspace sample
{
var dynamicLayerInfos:Array = usaLayer.createDynamicLayerInfosFromLayerInfos();
dynamicLayerInfos.unshift(lakesDynamicLayerInfo);
usaLayer.dynamicLayerInfos = dynamicLayerInfos;
usaLayer.layerDrawingOptions = [ lakesLayerDrawingOptions ];
}
You must know the name of the layers you are adding. In addition, the ArcGIS Server account
must have at least read access to the dynamic workspace that contains the data you wish to
dynamically add to the map service.
Additional Resources
Dynamic workspaces are enabled outside of the web APIs using ArcGIS for Desktop or
Manager. More information on setting the map service properties can be found atSetting map
service properties. See Making your data accessible to ArcGIS Server for additional information
regarding setting permissions on these workspaces.
Dynamic Rendering
In this topic
Dynamic symbology
Dynamic labeling
Additional Resources
Version 3.7
This topic discusses various ways of dynamically altering the rendering of map service layers.
These options include: updating symbology, labeling features, and changing layer order
dynamically.
Dynamic symbology
The following provides a couple of different options to consider when dynamically symbolizing
your data:
Taking existing renderers and applying to server-side features
Prior to ArcGIS 10.1 and the 3.x version of the Flex API, you would have sent the features from
a service client-side using either a GraphicsLayer or a FeatureLayer and then possibly
symbolized them based on a given renderer. Now, you can take advantage of dynamic
symbology by using this existing 'legacy' code that created these renderers and instead of
applying them client-side to either the GraphicsLayer or FeatureLayer, you can now apply the
renderers to the map service features.
How do you apply existing renderers to server-side features?
The main difference is that the renderer is now applied using the LayerDrawingOptionsproperty
of the dynamic map service layer instead of applying it to the GraphicsLayer or FeatureLayer.
Both samples, RangeValueRenderer and UniqueValueRenderer, show this behavior.
Small snippet taken from RangeValueRenderer sample.
<!--SimpleFillSymbol {SFS} set client-side...-->
<esri:layerDrawingOptions>
<esri:LayerDrawingOptions layerId="2">
<esri:ClassBreaksRenderer field="RENTER_OCC">
<esri:ClassBreakInfo label="0 to 500"
maxValue="500"
minValue="0"
symbol="{sfs0}"/>
...
Another option is to have ArcGIS Server generate renderers that can then be applied to dynamic
services. A new task was introduced with the Flex 3.x API calledGenerateRendererTask.
Note:
The GenerateRendererTask's source property can also be a dynamic layer that does not exist in a
map service. The sample, Thematic maps by table join, uses attributes from a joined table that is
not in a map service.
Dynamic labeling
New at ArcGIS 10.1 is the ability to alter a map service during the request and change its
rendering. This includes the ability to generate on-demand labels for features. In the previous
section we discussed working with the LayerDrawingOptions class and how useful it is to
modify symbology of a dynamic service. This class has the showLabels,scaleSymbols,
and labelClasses properties to aid with dynamic labeling. Setting showLabels=false indicates that
labels will not be displayed within the map. You must explicitly set this property for it to be
recognized. Setting the scaleSymbols property to false stops the layer from rendering its
symbols based on scale. Similar to showLabels , this must be explicitly set for it to be used.
The labelClasses property is an array ofLabelClass objects that is used to declare what will be
labeled. By using various LabelClasses and setting scale thresholds you can control how features
are labeled. You can achieve this by labeling features with different fields using the
LabelClass'labelExpression property. You can also control what labels are displayed by filtering
them using the where property.
Snippet taken from Dynamic labeling sample
<esri:layerDrawingOptions>
<!-- Layer drawing options for the states layer -->
<esri:LayerDrawingOptions layerId="3" showLabels="true">
<esri:ClassBreaksRenderer field="RENTER_OCC">
<esri:ClassBreakInfo label="58,094 to 216,867"
maxValue="216867"
minValue="58094"
symbol="{sfs0}"/>
...
...
<esri:labelClasses>
<esri:LabelClass id="initialLabelExpression"
labelExpression="[RENTER_OCC]"
labelPlacement="esriServerPolygonPlacementAlwaysHorizontal"
maxScale="18489298">
<esri:LabelOptions haloColor="0xFFFFFF" haloSize="2"/>
...
...
Additional Resources
Generate renderers
Unique value renderer
Range value renderer
Change layer ordering
Thematic maps by table join
Join to dynamic workspace
ArcGIS Help - Standard classification methods in ArcGIS
ArcGIS Help - Using unique values to display categories
Displaying data
Version 3.7
Displaying data
When displaying information in your web application, it is important to consider whether the
data should be displayed as client-side graphics or, rather, a server-generated image result. There
are many factors to consider when choosing which option works most efficiently. Below are just
a couple of considerations. These are not all-inclusive but are provided as an example for some
things you may want to consider when developing your ArcGIS API for Flex web application.
Network payload
In other words, how much data is being transmitted over the network from the server hosting
ArcGIS Server or Online and the client, e.g. the web browser displayed the web application.
Generally, any data that is returned via a task, e.g. a query, would be in the form of
a FeatureSet object. The FeatureSet object contains an array of graphicsfeatures. These features
are Graphic objects. A graphic contains geometry, attributes, and a symbol. All of this is returned
from the server in either: JSON format or AMFformat.
One consideration when determining network traffic is the level of detail per feature. Returning a
FeatureSet of 50 simple points, e.g. cities, will not be the same as returning a FeatureSet of 50
detailed polygons, e.g. counties with non-generalized boundaries. Ideally, you would want your
information to pass from server to client or vice-versa as quickly as possible. Two common
examples of information transfer can be seen in the scenarios below:
Tip:
If trying to determine network traffic between server and client, a good resource to use are
browser-based tools such as Mozilla's Firebug for Firefox, Internet Explorer's Fiddler, Developer
Tools for Google Chrome, and/or Safari's Web Inspector.
Performance
When many graphics are rendered, especially those with complex geometries, client-side
performance can suffer. Please see Performance considerations in the Query topic for more
detailed suggestions. When specifically working with a query, a couple of suggestions to
increase performance are to use generalized copies of data whenever possible or provide
the maxAllowableOffset to generalize the returned geometry.
Please see the following examples for more information on how to use maxAllowableOffset:
Rendering
Think about how results should be generated and how does the end user of your web application
need to interact with these results. Question whether it is necessary for all of the information to
be sent client-side in order to interact with the data. For example, should you mouse over a
feature to see a tooltip? Or, as an alternative, could you generate the result server-side and just
display the returned image? How many features are drawn at various scale levels? Use scale
dependencies if appropriate. Prior to ArcGIS 10.1 and the Flex 3.x API, most web applications
used client-side graphics for display scenarios. Now with 10.1 and 3.x, there are more options to
render content server-side and display results on the client. More information regarding how this
is accomplished can be found in the Dynamic Workflows section of the help.
Pop-up windows
In this topic
Version 3.7
Pop-up windows are windows that provide information about features. Pop-up
windows can include descriptive text, links, images, and charts. Pop-up windows
can be created with the ArcGIS API for Flex and the new PopUpRenderer class.
They can also be created on ArcGIS.com using the ArcGIS.com map
viewer or ArcGIS Explorer Online.
A feature on the map can have descriptive information that is displayed in a popup window when you click the feature. This descriptive information can include a
title, text, links to other websites, media elements such as an image, or a graph
derived from the properties of the feature. It can also provide links to attachments
of the feature.
You can configure what is displayed in the pop-up window for the features in
each layer in the map, specifying how the fields (attributes) of each feature are
represented in the pop-up window. You can also configure the pop-up window in
several different ways.
To display a pop-up window for a feature, click the feature on the map. Some features may not
be configured to show a pop-up window. When viewing a feature's pop-up window, you can
interact with the content to click links, interact with media, open attachments, and so on.
If the pop-up content has multiple media elements, you can click the arrows on the sides of the
pop-up window to page through each media element.
To close a pop-up window, click the close button at the top right of the pop-up window, or click
anywhere on the map.
Additional references
Version 3.7
download. These skins can be used as a starting point to create a custom look and feel for your
application. There are some alternate skins available in the download that can readily be used in
your applications. The source code for the skin classes can be found under
the <Extracted_API_Download_Location>/src/com/esri/ags/skins folder. See the following
screen shot:
To get a better understanding of the Flex framework's styling and skinning architecture, read
Adobe's Enhancing the user interface.
For specific information on how to change the appearance of the different ArcGIS API for
Flex components, see Navigation or ScaleBar.
Version 3.7
The following table shows various ways to change the navigation slider:
Different ways of changing the navigation slider
Different zoom
custom skin:
The CSS style property places the slider at a distance of 30 pixels from the top and right margin
on the map. Since the left property is a default property, you have to use the not a number
(NaN) value so that the left property value is not used.
Notice the @namespace directive and the qualified reference to the esri|Navigation scale bar.
Components whose attributes are changed need to be uniquely identified to avoid class name
collision.
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
esri|Navigation
{
top: 30;
right: 30;
left: NaN;
}
</fx:Style>
The default orientation of the navigation slider is vertical. Depending on your application
requirements, you can change the orientation of the navigation slider to horizontal. An alternate
skin is available in the application programming interface (API) that can be used for this
purpose. The reference to this alternate skin class is set as shown in the following code:
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
esri|Navigation
{
skin-class: ClassReference("com.esri.ags.skins.NavigationHorizontalSkin");
}
Creating a custom skin can further enhance the look of the navigation slider. In the following
screen shot, alternate images are used for the zoom-in and zoom-out button, and the tooltip is
customized to display tile level (instead of map scale).
You can modify the default skin class of the navigation control to create an alternate look. Do the
steps in the following sections to create this new look:
Copying the default skins used by the navigation control into your project
This is the default skin class that consists of the slider, and buttons for zooming in and out of the
map. Modify this skin to provide a new format for the tooltip and change the skins for the zoomin and zoom-out buttons.
1. Do the following to modify tooltip value:
Refer to the function formatSliderDataTip . This function is used to calculate the value for the
tooltip that is visible when the thumb of the slider is pressed. By default, the tooltip is set to the
scale of the map. It is modified as follows to display the tile level:
private function formatSliderDataTip(value:Number):String
{
const lod:LOD = hostComponent.map.lods[value];
return lod ? (lod.level + 1).toString() : "Error";
}
CSS properties are used to change the ToolTip appearance. The modified ToolTip has a blue
background with a bold font type. The CSS class selector looks like the following:
<fx:Style>
.tooltipStyle
{
backgroundAlpha: 1.0;
backgroundColor: haloBlue;
fontWeight: bold;
color: white;
}
</fx:Style>
The defined style class is set to the dataTipStyleName property of the slider as shown in the
following code:
<mx:VSlider id="slider"
dataTipFormatFunction="formatSliderDataTip"
...
dataTipStyleName="tooltipStyle"/>
3. Do the following to change the skin class for the zoom-in and zoom-out buttons:
Set new skin class references to the zoom-in and zoom-out button. The new skin classes change
the icons for the buttons. You will create these referenced skin classes in the subsequent step.
<s:Button id="zoomInButton"
...
skinClass="MyNavigationZoomInButtonSkin"
... />
...
<s:Button id="zoomOutButton"
...
skinClass="MyNavigationZoomOutButtonSkin"
... />
name="normal"/>
name="disabled"/>
name="normalWithSlider"/>
name="disabledWithSlider"/>
<s:Rect bottom="0"
left="0"
radiusX="10"
radiusY="10"
right="0"
top="0">
<s:fill>
<s:SolidColor alpha="0.5" color="0x000000"/>
</s:fill>
</s:Rect>
<s:VGroup gap="2"
horizontalAlign="center"
minHeight="34"
paddingBottom="5"
paddingLeft="3"
paddingRight="3"
paddingTop="4">
<s:Button id="zoomInButton"
enabled.disabled="false"
enabled.disabledWithSlider="false"
skinClass="MyNavigationZoomInButtonSkin"
toolTip="{resourceManager.getString('ESRIMessages', 'zoomInTooltip')}" />
<mx:VSlider id="slider"
dataTipFormatFunction="formatSliderDataTip"
dataTipPlacement="left"
enabled.disabled="false"
enabled.disabledWithSlider="false"
enabled.normalWithSlider="true"
height="160"
includeIn="normalWithSlider,disabledWithSlider"
liveDragging="false"
maximum="{hostComponent.map.lods.length - 1}"
showDataTip="true"
Change the bitmap image that is used as the icon image to display the zoom-in button. The
following code shows an image file named home_icon.png that is used as the source for the
bitmap image to display the button:
<s:BitmapImage
bottom="0"
...
source="@Embed(source='/assets/home_icon.png')"
source.disabled="@Embed(source='/assets/home_icon.png')"
source.down="@Embed(source='/assets/home_icon.png')"
source.over="@Embed(source='/assets/home_icon.png')"
/>
name="disabled"/>
name="down"/>
name="over"/>
name="up"/>
<s:BitmapImage
bottom="0"
left="0"
right="0"
Change the bitmap image that is used as the icon image to display the zoom-out button. The
image file, globe_icon.png , is used as the source for the bitmap image that is used to display the
button.
<s:BitmapImage
bottom="0"
...
source="@Embed(source='/assets/globe_icon.png')"
source.disabled="@Embed(source='/assets/globe_icon.png')"
source.down="@Embed(source='/assets/globe_icon.png')"
source.over="@Embed(source='/assets/globe_icon.png')"
/>
name="disabled"/>
name="down"/>
name="over"/>
name="up"/>
<s:BitmapImage
bottom="0"
left="0"
right="0"
source="@Embed(source='/assets/globe_icon.png')"
source.disabled="@Embed(source='/assets/globe_icon.png')"
source.down="@Embed(source='/assets/globe_icon.png')"
source.over="@Embed(source='/assets/globe_icon.png')"
top="0"
/>
</s:Skin>
The modified skin class can now be used in your application by setting the reference in the skin
class property. The following code shows the modified skin class referenced in the application:
<?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:esri="http://www.esri.com/2008/ags">
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
esri|Navigation
{
skin-class: ClassReference("MyNavigationSkin");
}
</fx:Style>
<esri:Map >
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
</esri:Map>
</s:Application>
Choosing the unit system to display (for example, only metric units) using an alternate
skin
Version 3.7
The position and visual attributes of the scale bar can be changed by using the
Cascading Style Sheets (CSS) style properties and/or a custom skin.
Show only metric units using an alternate skin. See the following:
Notice the "@namespace" directive and the qualified reference to the scale bar "esri | ScaleBar".
Components whose attributes are changed need to be uniquely identified to avoid class name
collision.
Since the "left" property is the default property, set it to not a number (NaN) to allow other
position properties such as "right" and "bottom" to take effect.
Similarly, the following code snippet positions the scale bar in the upper right hand corner on the
map.
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
esri|ScaleBar
{
left: NaN;
right: 5;
The ArcGIS API for Flex ships with the source code for the default skin classes of all the visual
components. The default skin class used by the ScaleBar component is
"com.esri.ags.skins.ScaleBarSkin" and is located under the
<Extracted_API_Download_Location>/skins/src" folder.
Copy the file ScaleBarSkin.mxml in to the "src" folder of your Flex project and rename the file
to MyScaleBarSkin.mxml. See the following:
Since you only need metric units displayed in the scale bar, delete the code for calculating U.S.
units, label for displaying U.S. units, and the line components. The modified code of the skin
resembles the following:
<s:Skin 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="200">
<fx:Metadata>
[HostComponent("com.esri.ags.components.ScaleBar")]
</fx:Metadata>
<fx:Script>
<![CDATA[
override protected function measure():void
{
labelMetric.text = hostComponent.textMetric;
labelMetric.x = hostComponent.lengthMetric labelMetric.getExplicitOrMeasuredWidth() * 0.5;
super.measure();
}
]]>
</fx:Script>
<s:Label id="labelMetric" fontFamily="Verdana" fontSize="9" y="0"/>
</s:Skin>
You can now add a rectangle to display the distance in metric units. The code for the skin class
resembles the following:
<s:Skin 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="200">
<fx:Metadata>
[HostComponent("com.esri.ags.components.ScaleBar")]
</fx:Metadata>
<fx:Declarations>
<s:SolidColorStroke id="solidColorStroke" color="0x000000" weight="2"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
override protected function measure():void
{
labelMetric.text = hostComponent.textMetric;
labelMetric.x = hostComponent.lengthMetric + 5;
super.measure();
}
]]>
</fx:Script>
<s:Rect width = "{hostComponent.lengthMetric}" height="5">
<s:fill>
You have now added a rectangle with red as the fill color. Also note that the "x" position of the
label "labelMetric" has been adjusted to be placed at the end of the rectangle.
Setting a reference to the modified skin class
Now that you have modified the skin class, it needs to be referenced using the "skin-class"
property in the application. The following code snippet shows how to reference the modified
skin class in the application:
<?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:esri="http://www.esri.com/2008/ags">
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
esri|ScaleBar
{
skin-class: ClassReference("MyScaleBarSkin");
}
</fx:Style>
<esri:Map >
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
</esri:Map>
</s:Application>
You can see that by changing the skin class, you can create different variations for the visual
appearance of the scale bar without changing any of the business logic of how the distances are
calculated.
Geocoder
In this topic
Additional Information
Version 3.7
The Geocoder component provides easy map navigation by adding a search box. This search box
enables users to move to a location much quicker and easier than standard panning/zooming. The
search box provides the search capabilities based on a given locator service and/or map services.
This component wraps pre-built search functionality directly in it so all you need to do is
reference the component within your application. If working with a locator, the component
defaults to the ArcGIS Online World Geocoding Service. It can also be customized to work with
another defined geocoding service. In addition to geocoding services, the Geocoder component
also has the ability to work with or without layers within your map service. You specify how you
wish the component to work by using either a geocoding service, map service layer(s), or both.
This component provides properties such as whether you wish to have the results autocomplete
and navigate once found. You can also specify whether you wish to work
with GeocoderLocatorOptions.. A couple of these options include properties such as what fields
you wish to display in the resulting features and the search extent used when geocoding.
This geocoding capability works off of a locator service that is configured to use a single line
address field.
Note:
If using your own geocode locator service, it will need to be configured to use single line style
similar to how the default locator service is configured.
If you wish to search using map service layer(s). Reference the mapServices property on the
Geocoder component. This property takes an array of geocoderMapServices. Here, you can
specify the layerids you wish to search, fields to search, and so forth. The selected search result
is returned as a GeocoderSearchResult. After the results display, listen for
the resultSelected event and handle the results as needed.
Additional Information
See the Geocoder API sample for additional details.
In addition to the API sample, you may also want to take a look at the GeocoderComponent in
the ArcGIS Viewer for Flex application. This takes the underlying Geocoder component and
uses it to perform similar search functionality within the Viewer. The source for the Viewer can
be accessed from Github. Once in the application, you can find this component
under src/com.esri.viewer/components .
Using Query
In this topic
Version 3.7
Tip:
In addition to using a query task, you may also want to consider working with a FeatureLayer as
it provides similar functionality. More information can be found at the FeatureLayer topic in
addition to the sample, Search with FeatureLayer.
Query task
In this topic, you will learn how to use a query task to query information from ArcGIS for Server
service. You will use Query, QueryTask, and FeatureSet to query a layer in a map and display
the results. The typical four steps involved in a query process are as follows:
1. Set up the Map and GraphicsLayer.
2. Set up the query task with a query filter.
3. Execute the query task with user inputs, for example, by selecting features on a map, choosing a value
from a list, or typing a value.
4. Display the query results returned in a FeatureSet. The FeatureSet is comprised of both geometry and
attributes of the selected features. The geometry can be used for highlighting the features on the map
and attributes can be used to populate aDataGrid or a ToolTip.
The example used in this topic is a QueryTask where the user types in the name of a city. Based
on this input, all cities that match the name are displayed on the map. See the complete code at
the end of the Executing the query section.
Setting up the layers
The Map and its layers are used to provide a context to displaying the query results. The
GraphicsLayer is used to symbolize and display the geometries of the query results. The
following code snippet shows a map with an ArcGIS Server tiled map service layer and a
graphics layer added to the map. The features that are rendered by the graphics layer will use the
symbol defined by infoSymbol1 , which is explained later in this topic.
<esri:Map id="map">
<esri:ArcGISTiledMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/
It is not always necessary to have a map to perform a query. In situations where you just want to
populate a DataGrid with the query results, a map is not needed. See the Query result in
table sample as an example.
Setting up the query task
The QueryTask is set to a uniform resource locator (URL) of the layer that the query will work
against. The URL includes the layer ID. In the following code example, the layer ID is 0:
<esri:QueryTask id="queryTask"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/
Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0"
/>
The Query defines the criteria that will be used for executing the query. The actual filter is set by
the text attribute , i.e. shorthand for a WHERE clause using LIKE operator that is bound to the
value of a text input component that is discussed later in this topic. The field used is the display
field defined in the map document. You can determine the display field for a layer in the
Services Directory. Since you're going to display the results of the query, set
the returnGeometry attribute to true.
In this example, a list of output fields is included in outFields. When you specify the output
fields, limit the fields to only those you expect to use in the query or the results. The fewer fields
you include, the faster the response. You must use the actual field names rather than the aliases
although these aliases can be used in the results.
<esri:Query id="query" text="{qText.text}" returnGeometry="true">
<esri:outFields>
<mx:String>CITY_NAME</mx:String>
<mx:String>STATE_NAME</mx:String>
</esri:outFields>
</esri:Query>
Note:
If querying a Featurelayer, set the returning outfields on the Featurelayer rather than the query.
More about this and Featurelayers can be found at Feature Layer.
Executing the query
Displaying the results of the query involves adding the symbology to the graphic and adding the
graphic itself to the graphics layer. The symbology can be applied directly to a graphics layer,
and all graphics added to that graphics layer will then inherit that symbology.
Recall that when you added the graphics layer, you set the symbol to infoSymbol1 . The
following code shows the declaration of infoSymbol1 , which is a symbol of typeInfoSymbol.
The InfoSymbol has an infoRenderer that defines how information is rendered. In the following
example, data.CITY_NAME and data.STATE_NAME are the outfields that were previously set in the
query.
Copyright 2016 Esri. All rights reserved.
If the infoRenderer component inherits from a parent that implements IDataRenderer, all the
attributes of the graphic are available via the dataproperty. In the following example, the
component VBox has a parent 'container' that implements IDataRenderer. For more information,
refer to the Adobe Flex 3 Language reference.
<esri:InfoSymbol id="infoSymbol1">
<esri:infoRenderer>
<mx:Component>
<mx:VBox>
<mx:Label text="{data.CITY_NAME}"/>
<mx:Label text="{data.STATE_NAME }"/>
</mx:VBox>
</mx:Component>
</esri:infoRenderer>
</esri:InfoSymbol>
After the successful execution of the query, the callback function onResult() is called. One of
the arguments to the function is a FeatureSet object that contains the results of the query. The
features of the FeatureSet can be directly assigned to thegraphicProvider of the graphics layer to
be rendered on the map.
In case of a failure, the callback function onFault() is called, which, in the following example,
shows an alert box with information about the failure:
private function doQuery():void
{
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null ):void
{
myGraphicsLayer.graphicProvider = featureSet.features;
}
function onFault(info:Object, token:Object = null):void
{
Alert.show( info.toString() );
}
}
The following is the complete code for the scenario discussed in this topic:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:s="library://ns.adobe.com/flex/spark"
pageTitle="Query Task (with a map)">
<s:layout>
<s:VerticalLayout gap="10"
horizontalAlign="center"
paddingBottom="20"
paddingLeft="25"
paddingRight="25"
paddingTop="20"/>
</s:layout>
<fx:Script>
com.esri.ags.Graphic;
com.esri.ags.FeatureSet;
mx.controls.Alert;
mx.rpc.AsyncResponder;
Performance considerations
There is a direct correlation between performance and the number of features selected; certain
queries are unrealistic or request too much data. The following list offers suggestions to enhance
performance:
If a large number of features is selected, it can take some time to draw the graphics on the map.
The type of feature also makes a difference. Points draw much faster than lines and polygons.
Therefore, use point graphics, e.g. MapPoint or MultiPoint , whenever possible.
If you're retrieving tabular data and don't intend to add graphics to the map, you should not
request geometry.
If queries are too large on a regular basis, limit the query to a smaller area or refine the query so
fewer features are returned at one time.
To prevent queries that request unlimited numbers of features (for example, empty WHERE
statements and statements that are always true), use MaxRecordCount to set the maximum
number of features. By default, the maximum for ArcGIS Server 10.x is 1000 features, 500
features for ArcGIS Server 9.3. Prior to ArcGIS for Server 10.1, you could modify this for a
specific MapService in its configuration file. For a default windows installation, the file
is C:\Program Files\ArcGIS\server\user\cfg\[YourMapService].cfg . As of version 10.1,
this can easily be configured when publishing your map service, see Editing service properties in
Manager, specifically the Maximum Number of Records Returned by Server parameter listed
in the Parameters tab on the left.
Queries on cached layers don't have scale dependencies. This means that features for a layer
can be queried even if the layer is not displayed on the map for a given scale. Thus, your query
should not be accessible for a layer if displaying the results does not make sense to the end user.
Editing
Copyright 2016 Esri. All rights reserved.
In this topic
Version 3.7
The ArcGIS APIs for Flex and JavaScript have the ability to edit geographic data over the Web.
Since a Web browser is a simple, familiar and free application, Web-based editing allows a
larger group of people to add and improve on your data. These include field workers, analysts in
other departments of your company, or perhaps even crowd-sourced volunteers who may be able
to make valuable contributions to your data given a simple editing interface.
The APIs include components (or widgets) that help you add editing functionality to your
applications. You can do some design work in both your map and your Web application to
simplify the end user experience when editing. For example, you might predefine a set of feature
templates, introduced at 10.0, to make it easier for users to add certain types of common features.
You might also limit the attributes that can be added, and add some available attribute options in
a drop down list to facilitate accurate, uniform data entry. As the designer of a Web editing
application, you have complete control over how simple or complex of an editing experience you
expose to your users.
Web editing requires some initial setup of a feature service, which exposes information about a
layer's feature geometries and attributes. Also, geometry services can be used to accomplish
some Web editing tasks. In order to use the main Editor component, for example, you must have
a running geometry service.
What can I do with editing in the ArcGIS Web APIs?
The ArcGIS Web APIs provide simple feature editing. The features must come from an ArcSDE
geodatabase. This geodatabase can be licensed for either workgroup or enterprise use and does
not have to be versioned.
When editing data with the Web APIs, you can add, delete, cut (split), merge (union), and
reshape features. You can also edit feature attributes. If you attempt to modify the same feature
at the same time as someone else, the last edits to be made are the ones committed to the
database.
For certain Web editing workflows, it is a good idea to have an analyst using ArcGIS for
Desktop periodically review the edits to verify data integrity. Although the editing components
can perform some data validation, other tasks such as validating topologies cannot be performed
over the Web.
The ArcGIS API for Flex provides multiple components to make it easier for you to add editing
functionality to your Web applications.
Editor component
If you want to get started quickly, or if you just want to use the default editing interface included
with the API, use the Editor component. The Editor component combines the functionality of the
other components to provide everything that you need for editing a layer. You can choose the
number and types of tools that are available on the component.
The Editor component saves your edits immediately after they are made, for example, as soon as
you finish drawing a polygon. If you decide not to use the Editor component, you must
determine for yourself when and how often you want to apply edits.
If you don't use the Editor component, you need to code your own editing experience. However,
you can still take advantage of the DrawTool, EditTool, TemplatePicker, AttributeInspector and
AttachmentInspector to help you - as shown in the Edit without Editor sample.
TemplatePicker component
The TemplatePicker component displays a set of pre-configured feature choices that the user can
create. The Template Picker is a great way to expose pre-configured feature types for easy
editing and quality control. The symbols in the Template Picker come directly from the editing
templates that you defined in the map document of your feature service.
A Template Picker is included in the Editor component. The Template Picker can also be used
on its own as a simple legend for your map.
AttributeInspector component
When you make attributes available for editing on the Web, you need to provide an interface for
users to edit the attributes, and you must ensure that the data they enter is valid. The Attribute
Inspector component can help you with both these tasks.
The Attribute Inspector reads the attribute fields available through your feature layerand provides
a user interface for easily updating those fields. It also validates data entered in the fields,
ensuring that the input matches the expected data type. For example, if a coded value domain is
applied to a field, the permitted values appear in a drop down list, restricting the possibility of
other values being entered. If a field requires a date value, a calendar appears, helping the user to
supply a valid date.
The Attribute Inspector exposes the available attributes on the layer for editing. Use the
outFields property on the FeatureLayer to set the available attributes.
An Attribute Inspector is included in the Editor component.
AttachmentInspector component
In some situations, you may want to associate a downloadable file with a feature. For example,
you might want users to be able to click a feature representing a piece of real estate and see a link
to a PDF file of the title deed. In the ArcGIS Web APIs, an associated downloadable file like this
is known as a feature attachment. See the FAQ onHow do I upload large attachments.
The AttachmentInspector component helps users upload and view the list of feature attachments.
The Attachment Editor includes a list of current attachments (with Remove buttons), as well as a
Browse button that can be used to upload more attachments. The Attachment Editor works well
inside an InfoWindow, but can be placed elsewhere on the page.
In order to use feature attachments, attachments must be enabled on the source feature class. You
can enable attachments for a feature class in ArcCatalog or the Catalog window in ArcMap.
RelationshipInspector component
Many times while viewing features, either in the form of a pop-up dialog or even a table, you
may wish to view, or possibly edit, any related features or records associated with that feature.
The RelationshipInspector component was added with version 3.1 and allows end-users to view
related records for features as well as add or delete related records.
You can think of this component as a 'building block' used in other components. For example,
you could use this in both the Pop-up window and/or an AttributeTablecomponent. This
component's functionality and use is very similar to the AttachmentInspector component. For
example, you can view and add attachments on a given feature. Many times you can view the
associated attachment inside a pop-up window. The same premise can be applied to relates as
well.
Note:
Adding of related records using the RelationshipInspector component is only supported when
using ArcGIS 10.1 or later. Also, the related "table" is an actual table and not a layer. Also
adding of related records is not supported if the cardinality is defined as 1-to-1 and there is
already a related record for a given feature.
Tip:
In order for your ArcGIS service to have relationships, your geodatabase needs to have
relationship classes or you need to configure relates in the map document. For more information
about configuring your service to support related records, read the ArcGIS Help.
Web editing requires a feature service to provide the symbology and feature geometry of your
data. The feature service is just a map service with the Feature Access capability enabled. This
capability allows the map service to expose feature geometries and their symbols in a way that is
easy for Web applications to use and update.
Before you build a Web editing application, you need to do some work to create a feature service
exposing the layers that you want to be edited. This involves setting up a map document and,
optionally, defining some templates for editing. Templates allow you to pre-configure the
symbology and attributes for some commonly-used feature types. For example, to prepare for
editing roads, you might configure templates for "Controlled Access Freeway", "Other Divided
Highway", "State Highway", and "Local Road". Templates are optional, but they make it easy
for the end user of the application to create common features.
Once your map is finished, you need to publish it to ArcGIS Server with the Feature Access
capability enabled. This creates REST URLs, or endpoints, to both a map serviceand a feature
service. You will use these URLs to reference the services in your application.
Feature services are accessible in the Web APIs through a new type of layer called afeature
layer. Feature layers can do a variety of things and can reference a layer in either a map service
or a feature service; however, when you use a feature layer for editing purposesyou need to
reference a layer in a feature service.
When you perform editing, your Web application tells the feature layer which attributes have
changed and, if applicable, how the geometry changed. The feature layer also displays the
updated features after editing. You can call the applyEdits() method on the feature layer to apply
the edits, which then commits them to the database.
The role of the geometry service
The ArcGIS Server geometry service helps perform common editing operations such as creating,
cutting, and reshaping geographic features. Before you use the Editor component, you need to
create a geometry service on your ArcGIS Server. Then when you create the Editor component,
you must provide the URL to the geometry service. The component uses the service behind the
scenes, and you won't have to call methods on the geometry service yourself unless you decide
not to use the component.
If you decide not to use the Editor component, you can still use the geometry service to help you
code your own editing tools. The geometry service can also help you validate data. For example,
you can use the geometry service to perform checks on edits, such as "no edit may fall outside
this box", or "a polygon boundary may not cross itself". The Editor component actually calls the
simplify() method on the geometry service before it commits a geometry to your database.
Although ArcGIS topology validation is not available through the Editor component or editingrelated classes, the geometry service may help you achieve a similar result through these types of
data integrity checks.
The EditTool
The EditTool helps you move graphics or their individual vertices. This is helpful in scenarios
where you are not using the Editor component and you need to write your own editing logic,
especially the client display behavior.
The DrawTool helps you create new features by drawing them. It is commonly used in
combination with the TemplatePicker to create new features based on the selected feature
template.
In this type of application, field analysts need to sketch simple events on the map, such as bird
sightings. The geographic precision of the edits is not as important as the event's attributes and
the fact that the event happened. In this type of an application, you can use a Template Picker to
limit the types of items users can sketch. The Attribute Inspector is also useful, either in a side
panel or in an info window that appears when the feature is clicked. Options for splitting and
merging features, adding a point at an X/Y location, snapping, or uploading feature attachments
may clutter the application and should be avoided unless absolutely needed.
View a sample that shows how to build a feature sketching application.
Attribute-only editing
Some editing applications include a mapping component, but don't require any changing of
geographic features. For example, you might want to create a Web application allowing any
office employee to edit the attributes of a parcel feature in your database. You want to prevent
them from editing the geometry, leaving that task to your GIS analysts. In this scenario, you can
include a map in your application, but expose editing only through the Attribute Inspector. A
simple map click on a parcel displays the attributes to be edited. You don't need to include any
buttons or components for creating, deleting, or reshaping features.
View a sample that shows how to build an attribute editing application.
In this type of application, citizens can be the editors and report problems to a government
organization by placing points on the map and including ancillary information such as
photographs or a brief description.
Users of this type of application do not even know that they are editing GIS data. They are only
allowed to add point features to the database, using a carefully selected set of incident types that
you predefined in a Template Picker. Attachments are allowed through the Attachment Inspector
component so that citizens can upload images of the incident. Attribute editing may be allowed
to a very limited degree so that citizens can describe the incidents.
In this type of application, you may have to code some security checks to ensure that users can
only edit or delete their own incidents. You may also include logic to periodically clean out the
database, or allow a subset of authenticated users to close or delete incidents.
View a sample that shows how to build a citizen participation application.
Tip:
To get a good idea of how editing works. The ArcGIS Viewer for Flex's edit widget's source
code provides a good example of how to implement and work with this functionality. You can
download and access this at github. If you downloaded the entire application, refer to the files
located in thesrc/widgets/edit folder.
AttributeTable
In this topic
Conceptual workflow
Additional references
Version 3.7
The AttributeTable component displays a tabular view of a feature layer's
attributes. If the feature layer is editable, you can edit the records within the table
widget as well. It recognizes layers added specifically as feature layers, whether
it be from a Feature Service or Dynamic Map Service. In addition to feature
layers that are directly added, it will also recognize any layers within a full
dynamic map service as well and display features within the extent.
Export the attributes to a CSV fileExports the attributes to a separate CSV file.
Note:
If records are selected, only the selected features are written to this file. If working with
point feature classes, two additional fields are also written into this CSV file indicating
latitude and longitude. This specific feature with points is only supported for Web
Mercator and Geographic spatial references.
Show attachmentsThis option is available if the feature layer has attachments enabled on it.
Show related recordsThis option is available if the feature layer has any associated
relationships.
Note:
If a Uniform Resource Locator (URL) exists as a field value in your service it will display as a
text string in the attribute table and not as a hyperlink.
If you are outside an extent and are not displaying any visible features, a message will appear
displaying "No features in current map extent". Also, if your scale is out of the visible range of
the layer, you will receive a message stating "Layer is out of scale range".
Conceptual workflow
Requires: Feature layers from either a dynamic map service or feature service.
Reads feature layers and populates the contents of the widget with the corresponding feature's
records within the current map extent. If more than one layer, multiple tabs will display in the
table.
Attribute table updates as feature(s) updates change with extent changes.
Interactive functionality between records and features in the map.
Edits can be performed on the records if the layer is editable.
Additional references
To test out this functionality, see the AttributeTable sample.
Directions
In this topic
Calculate directions
Additional Information
Version 3.7
Calculate directions
The Directions component provides a quick and efficient method of calculating directions
between two or more locations. Similar to how the existing routeTask works, this component
generates a route "finding a least-cost path between multiple services..." using a specified
network service.
This component wraps pre-built search and route functionality directly within it so all you need
to do is reference the component within your application. Starting with 3.3, the routing service
URL now defaults
to http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World . Prior
to this version 3.2, there was no default network routing service. This can be either a service
hosted by your own Server or one by ArcGIS Online (such as the default.)
Note:
ArcGIS Online Network Analysis Services require an ArcGIS Online subscription. Each
successful request to the service incurs service credits which are taken from your subscription.
More information regarding this can be found at Accessing Services topic of the Network
Analysis Services documentation.
The Directions component makes use of the Geocoder to determine the input locations. You can
perform this two ways:
1. Forward geocoding - this is handled via the standard method of typing an input location into a textbox.
2. Reverse geocoding - this is performed after clicking on a point within the map.
All of this is handled by setting the Direction's locatorURL property. This points to a geocoding
locator service. Please see the Geocoder topic for additional information on how this component
works.
Similar to how the Geocoder component works, you can also specify input locations using map
services. These services can be used on their own or in conjunction with a locator service. If
wishing to work with map services, you would set them via
theDirectionsGeocodeOptions.mapServices property. If you wish to only work with map
services, you would set the map services as previously stated, in addition to setting
the locatorURL property to null , you would also want to set the useMapServiceOnly to true .
Once the input locations are determine, you can calculate the directions. This takes whatever
network route service set on the Direction's URL property.
Caution:
It is not possible to determine input locations by clicking on the map if only working with map
services.
The advantage of using the Directions component is that it encapsulates all of this in its UI. All
you need to do is provide the input locations and a URL to a route service. The resulting
directions and its symbology are all handled by the component and displayed appropriately. In
addition to calculating from-to directions, you can also reverse the calculated directions, display
textual step-by-step directions including total distance and time, which in turn can then be
printed.
Additional Information
See the Directions API sample for additional details.
In addition to the API sample, you may also want to take a look at the Directions widget in the
ArcGIS Viewer for Flex application. This takes the underlying Directions component and uses it
to perform similar search and route functionality within the Viewer. The source for the Viewer
can be accessed from Github. Once in the application, you can find this component
under src/widgets/Directions .
Geoprocessing tasks
Copyright 2016 Esri. All rights reserved.
In this topic
Version 3.7
Geoprocessing allows you to automate your geographic information system (GIS) analyses by
creating custom tools and linking them within ArcGIS. You can arrange these tools in a logical
way to accomplish a multistep task in a single operation rather than a series of manually run
tools.
The Geoprocessor class in the ArcGIS API for Flex gives you access to various geoprocessing
tasks, which are exposed through services in the ArcGIS REST Services Directory.
To use the geoprocessing services, obtain the following information from the Services Directory:
From this page, you can see that the geoprocessing service Esri_Elevation_World is located in
the Elevation folder and runs on sampleserver1.arcgisonline.com.
The following page appears when you click the Viewshed geoprocessing model:
To execute this geoprocessing task, copy and paste the following MXML code into your
application:
<esri:Geoprocessor
id="gp"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/
Elevation/ESRI_Elevation_World/GPServer/Viewshed"
/>
Synchronous executionThe client executes the task and waits for a response before
proceeding. The Supported Operations section of the Services Directory displays 'Execute Task'
for synchronous tasks.
Asynchronous executionThe client submits a job, then verifies that it was successful using a
unique job ID. When the task completes, the client can retrieve the results. The Supported
Operations section of the Services Directory displays 'Submit Job' for asynchronous tasks.
To run a synchronous task, call Geoprocessor.execute(). Supply the input parameters for the task
and optionally include a callback function that tells the application how to handle the results:
gp.execute(params, myFunction);
The results of the task are returned to the callback function as an array ofParameterValue. If
messages are enabled, you also get an array of GPMessage objects.
You can loop through each item in the results array and add it to the map as shown in the
following code:
private function displayResult(event:GeoprocessorEvent):void
{
for each ( var myGraphic:Graphic in event.parameterValues[0].value.features )
{
myGraphic.symbol = viewshedSimpleFill;
myGraphicsLayer.add( myGraphic );
}
}
To run an asynchronous task, call Geoprocessor.submitJob(). Supply the input parameters and
optionally specify (1) a complete callback function to be called when the job is successful, and
(2) a status callback function when the geoprocessor checks the job status:
gp.submitJob(params, MyCompleteCallback, myStatusCallback);
The status callback receives a JobInfo object containing the job ID, the job status, and
any GPMessage objects returned by the geoprocessor.
Routing tasks
In this topic
Turn-by-turn directions
Advanced options
Version 3.7
When you create an instance of RouteTask, you provide a URL that is the REST endpoint to an
ArcGIS Server network analysis service. You can copy and paste the following MXML code
into your application:
<esri:RouteTask
id="routeTask"
url="http://tasks.arcgisonline.com/ArcGIS/rest/services/
NetworkAnalysis/ESRI_Route_NA/NAServer/Route"/>
To get the desired results from the route task, you need to specify the details of your routing
problem, such as stop locations, barrier locations, the impedance attribute, and so on. You do this
using RouteParameters. The following code example shows how to use RouteParameters to
define two stops for a route using ActionScript only. (See the Route samples at the bottom of this
page for an example of using a combination of MXML and ActionScript.)
var routeParams:RouteParameters = new RouteParameters();
var stop1:Graphic = new Graphic(new MapPoint(-117.21,34.065);
var stop2:Graphic = new Graphic(new MapPoint(-117.185,34.05);
var stops:FeatureSet = new FeatureSet([ stop1, stop2]);
routeParams.stops = stops;
For a complete description of each route parameter, see the RouteParameters entry in the API
reference.
Solve the route
Once you've created the route task and configured its parameters, you can
call RouteTask.solve() to solve the route.
routeTask.solve(routeParams);
In addition to calling the solve method, you need to handle the solveComplete and fault events
on the RouteTask. These functions define what the application will do with the results, whether
the result is a route or an error message.
<esri:RouteParameters
id="routeParams"
solveComplete="solveCompleteHandler(event)"
fault="faultHandler(event)"/>
Turn-by-turn directions
The RouteTask can return turn-by-turn driving directions between stops. To get the directions,
set RouteParameters.returnDirections to true.
routeParams.returnDirections = true;
Advanced options
Batch routingSolve multiple routes in one request. Stops with the same name will be grouped
into sets for solving individual routes. For the batch routing result, you'll get an array
of RouteResult containing each route.
Time windowsConstrain stop visits to certain times of day.
GeoEnrichment
In this topic
User experience
Infographics
InfographicsCarousel
Version 3.7
Starting with version 3.5, the ArcGIS API for Flex provides access to the ArcGIS
GeoEnrichment service. This service provides the ability to get facts about a
location or area. Using GeoEnrichment, you can get information about the
people, places, and businesses in a specific area or within a certain distance or
drive time from a location. GeoEnrichment capabilities allow you to answer
questions about locations that you can't answer with maps alone. What kind of
people live here? What do people like to do in this area? What are their habits
and lifestyles? What kind of businesses are in this area?
User experience
The two screen captures below depicts a typical user experience when working with
GeoEnrichment functionality using the ArcGIS API for Flex.
The first step is to click a location on the map to determine your study area and initiate a
GeoEnrichment task.
Next, the geometry of the study area and the infographic are returned.
Infographics
Multiple components fall under the GeoEnrichment umbrella. The Infographic and
InfographicsCarousel are the two main components you will use if working with GeoEnrichment
functionality. After you specify a study area and geometry, either the Infographic or
InfographicsCarousel automatically accesses the GeoEnrichment service where the information
you requested is properly summarized and visualized in tables or/and charts.
These componenst provides a graphic layout with the information about your study area. Three
types of Infographic components are available:
1. One variable - shown below with a custom skin
2. Related variables
3. Tapestry
Variables can be thought of as the types of data you can add and work with using the
GeoEnrichment service. An example of some types of variables could be:
Household income
Family size
Average home value
This is just a small sampling of the many variables you can access when working with
GeoEnrichment functionality. See the Explore GeoEnrichment Data Coverage sample to browse
the variables per country.
One variable Infographic
The screen captures provided in the user experience above displays a OneVar , or 'one variable',
type of Infographic. This type displays the value of single variable. In the example provided, the
variable displayed is 'average household size'.
The code snippet to create this is similar to the following:
<esri:Infographic id="infoGraphic"
width="100%" height="100%"
complete="infoGraphic_completeHandler(event)"
countryId="US"
fault="infoGraphic_faultHandler(event)"
loadStart="infoGraphic_loadStartHandler(event)"
type="OneVar"
//KeyUSFacts is the datacollectionID and AVGHHSZ_CY, the variable.
variableIds="['KeyUSFacts.AVGHHSZ_CY']" />
The Infographic component is created with a specified type and variableId . When working
with the Infographic component, the default URL it defaults to
is https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer . You
can override this default URL with your own endpoint. An example of this may be if working
with an internal Portal for ArcGIS installation.
Note:
In order to access the GeoEnrichment service, you need an ArcGIS Online subscription to either
an Organization plan or a Developer plan.
In addition to the type and variableId , you will also need to set the studyArea property. This is
what defines the location of the point or area that you want to enrich with additional information.
See the 'Study areas' section in the GeoEnrichment service overview topic for additional
information.
In the example shown above the studyArea is determined when the map is clicked or a buffer is
specified. The snippet below was taken from the map's mapClickHandler event.
...
var studyArea:GeometryStudyArea = new GeometryStudyArea();
studyArea.geometry = mapPoint;
studyArea.options = new RingBuffer([1], RingBuffer.MILES);
//GeographyLevel takes in a (countryId, datasetId, and layerId, the last required)
//Admin levels are aliases that correspond to various levels of geography for
each individual country
The GeometryStudyArea is created and is set to the geometry of the passed-in mapPoint . In
addition, options is set to the studyArea . These options will be applied to theStudyArea's
geometry to determine the area to enrich. See the StudyArea class' API reference for additional
information.
If the study area's geometry is a MapPoint or a Polyline , the GeoEnrichment service will create
a 1-mile ring buffer around the geometry to collect and append enrichment data. You can
optionally change the ring buffer size or create drive-time service areas around the geometry by
setting the options . In addition to this, there are three types of options you can set:
RingBuffer
DriveBuffer
IntersectingGeographies
See the samples provided in the GeometryStudyArea API reference for further information.
Each country has its own standard geography levels. These geography levels are what gets
passed in to the study
area's comparisonGeographyLevels property. comparisonGeographyLevels allows you to request
data for geography levels that intersect the study area. The Infographic displays the variables for
those levels, this allows you to compare them against the study area variables. Please see
the GeographyLevel API reference for additional information.
Last, the returnGeometry determines whether the geometry of your study area will be returned.
Since we would like to show the study area with the results on map, set it to true .
For the full code used in the snippet above, see the Infographic sample.
Related variables infographic
Another type of infographic is RelatedVariables . This type displays values of multiple variables
and the deviation with the comparison levels.
For the above sample, all that needed updated were a couple of properties in the Infographic.
First, the Infographic's type property was modified to RelatedVariables . Next,
the variableIds property was updated to reflect multiple variables. In this example, it displays
'Households by Income' for various ranges.
...
type="RelatedVariables"
///HouseholdsByIncome is the datacollectionID for all variables listed
variableIds="[HouseholdsByIncome.HINC0_CY_P,HouseholdsByIncome.HINC15_CY_P,
HouseholdsByIncome.HINC25_CY_P,HouseholdsByIncome.HINC35_CY_P,
HouseholdsByIncome.HINC50_CY_P,HouseholdsByIncome.HINC75_CY_P,
HouseholdsByIncome.HINC100_CY_P,HouseholdsByIncome.HINC150_CY_P,
HouseholdsByIncome.HINC200_CY_P]"/>
Tip:
If you wish to request all the variableIds in a data collection, you can do so using a wildcard (*).
For example, HouseholdsByIncome.* would iterate through all the variables within the
HouseholdsByIncome data collection.
Tapestry infographic
The last type of infographic is Tapestry . Tapestry classifies US neighborhoods into 65 market
segments based on socioeconomic and demographic factors. Please seeLifestyles-Esri Tapestry
Segmentation data for additional information on how this works.
In this sample, we updated the Infographic's type property to Tapestry and updated
its variableIds to reflect the Tapestry DataCollection's ID.
...
type="Tapestry"
///Tapestry is the datacollectionID and variables defined with a wildcard
variableIds="['Tapestry.*']"/>
InfographicsCarousel
The InfographicsCarousel component requests GeoEnrichment data for a specified location and
visualizes the results in a collection of Infographics. This collection of Infographics can be
scrolled through via its 'next' (right arrow) and 'previous' (left arrow) buttons.
The following screen captures display an InfographicsCarousel that shows both related variables
and tapestry types.
The code used to create the InfographicsCarousel is very similar to what is used when creating
an Infographic.
<esri:InfographicsCarousel id="carousel"
complete="carousel_enrichCompleteHandler(event)"
fault="carousel_faultHandler(event)">
This code snippet takes user input and returns GeoEnrichment data for a specified area.
The InfographicsCarousel component is declared within the markup. The GeometryStudyArea is
defined with its geometry set to the geometry specified by the user's input. The geography levels
are also set to US: Admin3 (US.Counties), Admin2 (US.States), Admin1 (US.WholeUSA) .
Once the carousel_enrichCompleteHandler event handler is fired, the resulting studyarea 's
geometry is set to the geometry of the graphic layer.
private function carousel_enrichCompleteHandler(event:InfographicEvent):void
{
...
//put the result geometry on the graphics layer
resultGeometry = event.studyAreaGraphics[0].geometry;
//zoom to the geometry
map.extent = resultGeometry.extent;
...
}
For the full code used in the snippet above, see the InfographicsCarousel sample.
Infographic, this sample illustrates how to work with a simple 'one variable' Infographic with the
option to specify a buffer.
Compare Infographic types, this sample demonstrates how to work
withIntersectingGeographies study area options. It also illustrates smaller skins for the
Infographics. A bar chart is used for the 'one variable' type. This is displayed in the first screen
capture at the top of this page.
InfographicsCarousel, this sample illustrates how to work with the InfographicsCarousel with
buffer options.
InfographicsCarousel custom skin, this sample demonstrates how to work with the
InfographicsCarousel using small and standard skin versions.
Enriching a GeometryStudyArea, this sample allows you to choose a location, and then specify
up to five variables to enrich the chosen location.
Using StandardGeographyQueryTask, this sample describes how to work with
theStandardGeographyQueryTask.
Explore GeoEnrichment Data Coverage, this sample allows you to browse geography levels, data
collections, and variables per country.
The links below provide additional help documentation when working with GeoEnrichment
functionality:
GeoEnrichment Service Overview topic situated in the ArcGIS REST API section Demographic
Developers.arcgis.com - GeoEnrichment
Enriching your data via Esri Maps for Office
Tapestry Segmentation in ArcGIS Online
Blog: Javascript developers meet GeoEnrichment
Infographic component API reference
InfographicsCarousel API component API reference
Supporting classes for the GeoEnrichment components
Supporting classes for the GeoEnrichment service and related tasks
Services Directory
Secured services
For more information on ArcGIS Server, visit the ArcGIS Server Resource
Center orcontact your local Esri representative. If you already own ArcGIS,
many support resources are available to help you get started and meet your
application needs.
In this topic
Version 3.7
The ArcGIS Services Directory, a component of the ArcGIS Server REST infrastructure,
contains information on the services available at each server.
Search for available services (including secured services, with proper login) and view service
details including the following:
Version 3.7
To use an ArcGIS Server service in the ArcGIS API for Flex, you need to know the URL of the
service. URLs can vary, but often resemble the following:
http://www.example.com/arcgis/rest/services/ExampleService/MapServer
Map layer IDsThese are necessary if you intend to identify or query on those layers.
Note:
IDs are usually integer values and are not the same as the layer name, which is assigned
by the author of the map.
Names of the attribute fields in a layerThese are needed if you intend to specify which fields
are returned from a query.
Other map informationSuch as the spatial extent of the map or individual layers, the feature
type of a layer (point, line, or polygon), or the minimum and maximum scales at which the layer
displays.
Secured services
In this topic
OAuth2-based authentication
Token-based authentication
HTTP/Windows authentication
Version 3.7
There are a few ways to handle security when working in applications built with the ArcGIS API
for Flex. Three methods used to manage user and/or app logins are as follows:
1. OAuth2-based authentication
2. Token-based authentication
3. HTTP/Windows-based authentication
These methods can be applied to various platforms, these platforms can be thought of as either:
Applications that target end users of the ArcGIS platform. These applications need to allow users
to login to the platform via the application. These types of logins are known as user logins.
Applications that target end users who are unknown to the ArcGIS platform. These applications
need to login to the platform on behalf of the application. These kinds of logins are known as
app logins.
User logins
User logins are probably the more familar of the two as this is what ArcGIS Server's existing
token-based authentication uses with the generateToken REST API call . If an application tries to
access a secured service, it requires a valid token to unlock the service. For example, a web
application that accesses a secure service can be configured to prompt a user for their user name
and password credentials. This specific end user would need to have permission set with the
platform so that their credentials can unlock this service. This user login is known to the
platform; in this scenario, the platform is a secured ArcGIS Server service.
Managing users and their roles can be handled various ways in ArcGIS Server. Please see
the Configuring ArcGIS Server Security top for additional information regarding how this
works.
App logins
When working with app logins, the application code logs into the platform on behalf of itself.
Simply stated, an application registered with ArcGIS.com can log in regardless of who is
accessing it. This is useful when it is not necessary to have users directly log in to access an
application. This can be the case in circumstances where you may not know all of the end users
accessing the application. You just need to make certain they have access to ArcGIS.com and the
resources within it. You will want to be cognizant of how the application is being used to avoid
any misuse since anyone can access it. This will be discussed further in the OAuth2
authentication section below.
OAuth2-based authentication
Beginning with version 3.5, support for OAuth2 authentication is provided directly in the
ArcGIS for Flex API's Identity Manager. This built-in functionality handles a lot of the finegrained work that you would typically have to do when implementing this type of authentication.
When working with OAuth2 authentication, the platform you work with is ArcGIS Online. If
you have an organizational account, you are able to register applications with this platform.
Please see the Adding items ArcGIS.com help topic for steps on how to do this.
When you register your application you need to add one or more redirect URIs. This is the URI
of the app and the URI to which the token will be returned. Once you register your application
with the platform, you will have an associated application ID (App ID) and application secret
(App Secret). These can be viewed similarly as a user name and password where the App ID is
open to the public and can be seen by everyone whereas the secret is kept confidential, similar to
that of a password.
The screen capture above displays the registered application's ID, type, and redirect URI's.
OAuth2-based authentication and user logins
When working with OAuth2-based authentication you can work with either user or app logins.
Applications that support user logins use OAuth2 to allow end-users to log in to the ArcGIS
platform via a login page. User login is performed in a single step which requires the application
to direct the browser to the OAuth2 authorization URL for the portal, for example arcgis.com.
https://www.arcgis.com/sharing/oauth2/authorize?
client_id = "RRGuEoGwvId9cs0I"&
response_type=token&
redirect_uri = http://resources.arcgis.com
Once the user logs in, the application receives a token that it can use to access the platform on
behalf of the user. The server returns a token by redirecting the browser to the
specified redirect_uri . This token needs to be sent to the platform with all requests.
The default expiration time for the token returned by this approach is two hours. To request an
token that is valid for a longer period provide an expiration time (in minutes) using
the expires parameter. The maximum expiration time set by the platform will override the
expiration time requested by the application.
The Identity Manager component simplifies the process of working with the token by appending
the token in all requests and acquiring a new token when necessary. The OAuthInfo class contains
information regarding the OAuth configuration such as the appID , expiration , locale ,
and portalURL . For additional information on this, see thereference.
For additional information on how to build a user login application, see the ArcGIS.com Web
Map (OAuth) sample that provides the ability to work with the Identify Manager to log-in and
access a web map in ArcGIS Online.
OAuth2-based authentication and app logins
Applications that target end users who are not known to the platform use application (app) logins
to connect to the platform. In this case the application will login to the platform on behalf of
itself and its end users will not be prompted for their credentials. Applications that use app logins
must use both the OAuth2 AppID and AppSecret .
Malicious users that gain access to both the AppID and AppSecret can access billable services on
ArcGIS.com, all of this billed to the application. Developers are responsible for keeping
the AppSecret confidential. This implies that the application will need to have a server side
application component that keeps the application credentials secure since client source code can
be inspected.
The server-side application component that has access to the applications credentials can obtain a
token using a single request by making a POST request to the portal's OAuth2 token endpoint
with an OAuth2 grant_type value equal to client_credentials .
http://www.arcgis.com/sharing/oauth2/token?
client_id = "RRGuEoGwvId9cs0I"&
client_secret = "this is where you would enter the app secret"&
grant_type = "client_credentials"
Successful authentication directly returns a JSON response containing the token that allows
access to resources shared with it.
To get a better idea of how a server side component handles the process of storing credentials,
acquiring the token, and appending it to all requests, view the resource proxy on GitHub. You
will also want to review the Using the Proxy Page help topic for details on how to work with the
proxy from an application built with the ArcGIS API for Flex.
View the Infographic or any of the other GeoEnrichment samples for an example of an
application that uses a proxy to store the authentication information. This information is what is
used to access the ArcGIS GeoEnrichment service used in the sample.
Token-based authentication
Token-based authentication services require that a token be included in each request for a map,
query, etc. ArcGIS Server, ArcGIS Online and Portal for ArcGIS all support token-based
authentication via a token service that can be used with both application and user logins. Upon
successful authentication the token service returns a token that needs to be appended to all future
requests.
The request to the token service must be made over HTTPS and all subsequent requests that use
the token also need to be made over HTTPS if required by the resource.
Token-based authentication and user logins
Applications that support user logins are responsible for providing a login dialog that prompts
users for their credentials. The application is responsible for keeping these credentials secure by
transmitting them over HTTPS.
If you are building an application that accesses resources from ArcGIS Online, Portal for ArcGIS
or services from ArcGIS Server 10.0 SP1 or later the recommended approach is to use the
Identity Manager to handle the process of gathering the credentials and acquiring and using the
token. To use the Identity Manager simply enable the Identity Manager component in your
application.
import com.esri.ags.components.IdentityManager;
IdentityManager.instance.enabled = true;
Applications that access secured resources using token-based authentication can do so via an app
login approach. This occurs when the user does not log in to the application by supplying
credentials. Rather, a generic 'user' will need to be provisioned with a supplied user name and
password. These credentials are then provided when making a request for a token to the token
service.
Developers are responsible for keeping the credentials a secret, including from users who inspect
browser source code using developer tools. This implies that the application will need to have a
server side application component that keeps the application credentials secure.
One way to do this would be via a proxy server-side component. The proxy could be written to
handle storing credentials, acquiring the token, and appending the token to all requests. View
the resource proxy on GitHub for an example.
HTTP/Windows authentication
When a request is made to a service secured with HTTP authentication (including Windows
authentication using IIS), the server issues an authentication challenge. The application or user
must respond with appropriate user credentials using standard HTTP authentication methods.
The two approaches to accessing a secured service using HTTP/Windows authentication are as
follows:
Use server-side code (ASP.NET, JSP, PHP, and so on) to set an identity for the request. The server
sends the request with the identity; the end user does not need to log in. For more information,
see Using the proxy page.
Do not supply any credentials within your application. Instead, let the server challenge the
browser user. The user will see a login dialog box in the browser and must provide a valid user
name and password for the ArcGIS Server system that issued the challenge. Work with your
system administrator to ensure that end users have login information. For additional
information on this, please see the ArcGIS Server help.
Additional Information
If HTTP Basic authentication is used, you should require that users employ HTTPS when
accessing your application to prevent password interception. Other authentication methods,
such as Digest or Integrated Windows Authentication, may protect user logins, but for maximum
security, HTTPS is recommended when users are logging in.
Authentication is required only for the initial request to the secure service. This may result in a
user encountering a login dialog box midway through a session. For example, if the user
requests a nonsecure map, then tries to perform a query on a secure server, the login dialog box
will appear only after the query. To avoid this, send a request in the background to the ArcGIS
Server system when the application starts, such as a simple REST request for service
information. The user would be prompted to log in on startup rather than when using the
application.
Supplying end users with a user name and password is not appropriate when services from
more than one ArcGIS Server system are used in an application, as multiple logins would be
required. This limitation does not apply when using multiple services within the same ArcGIS
Server system, since the challenge is issued for the entire server.
The ArcGIS API for Flex supports basic use of secured services from ArcGIS for Server 9.3 and
above. There is no support for ArcIMS secured services.
If you are the administrator of an ArcGIS Server system, you can restrict access to your ArcGIS
web services. Information on restricting access is available in the help documentation for ArcGIS
for Server.
If working in Internet Explorer using client certification authorization, an additional line needs to
be added to the HTML wrapper similar to what is displayed below.
<script type="text/javascript"
src="https://[server]/arcgis/rest/services?f=json&callback=String"></script>
Version 3.7
The service you are trying to connect to is on a different domain than your application, and the
service does not have a crossdomain file allowing your Flash application access.
The application uses a service that is secured with token-based authentication, and you do not
want to allow users to view the token, or you do not want to transmit the token over the
network between your web server and your users.
You are building an application that targets end users not known to the ArcGIS platform. In this
situation, the application will login to the platform using information stored in the proxy.
View Authentication, OAuth 2.0, and ArcGIS for details.
Note:
For a JavaScript application, a proxy page is also required when the requests exceed the limit on
the length of the uniform resource locators (URLs) imposed by the browser. This does not apply
to Flex API applications as the Adobe Flash Player can "POST" requests when needed.
To use the proxy page, you need to perform the following steps, which are described in detail as
follows:
1.
2.
3.
4.
Download and configure the proxy page appropriate for your server
Add code to your application page to enable use of the proxy
Test to ensure the proxy is working correctly
Secure the proxy application
or with ActionScript:
treasureMap.proxyURL = "URL to proxy"
// or with an absolute URL
If your application environment supports debugging mode, you may be able to set a breakpoint
in the proxy page and detect whether it is operating correctly.
For example in IIS/ASP.NET environment, you can open the application in Visual Studio
and set a break point in the ProcessRequest method in the proxy.ashx., then run the
application in debug mode. The execution should halt at the breakpoint, and you should
be able to detect where the problem is. You may also set breakpoints in your Flex
application, or insert trace() or Alert() statements to display values during execution.
Set the ProxyConfig mustMatch attribute to false to proxy all requests. If the application works
when this value is set to false then you may not have listed your service in
the serverUrls section or you may have a typo in the serverUrl. Don't forget to set this
attribute back to true when you have finished troubleshooting the proxy.
Enable logging for the proxy. Once enabled messages are written to the log that may be useful
when troubleshooting the issue.
Make sure you've specified the correct location for your proxy in your application code. You can
use browser developer tools to determine if the proxy can be successfully located. To do this,
activate your browser debugging tools then examine the network requests. Look specifically for
requests that POST to the proxy. If you see a 404 error this means that the proxy was not found.
Inspect the request properties to view the path where the application is looking for the proxy.
Deploying an application
In this topic
Production workflow
About crossdomain.xml
Deploying crossdomain.xml
Additional information
Version 3.7
Click Project > Properties > Flex Compiler, then uncheck the Enable integration with
browser navigation check box. Unless you've added code to specifically support deep links,
there is no need for this box to be checked.
If working with images, it is important to note that embedded resources do not get exported out
to the release folder. If you wish to reference an image, you will need to make sure that this
image is manually copied in the export build.
Production workflow
The compiled application (SWF file), its HTML wrapper, and its related files (for example,
shared libraries) can be moved onto any web server. There are no dependencies on any additional
files hosted by you (or Esri) at run time, because the compiled SWF file contains all the
necessary code.
When a web user accesses the HTML wrapper file, the browser verifies that Adobe Flash Player
is installed and is using the specified minimum Flash Player version. The client browser then
downloads the SWF file. At this point, the user might not connect back to this web server at all
but instead connect directly to the servers containing map content and tasks. If your web
application is not hosted on the same server as ArcGIS Server, you must have a crossdomain.xml
file on ArcGIS Server.
About crossdomain.xml
To access data from a server other than the one hosting your Flex application, the remote server
needs to have a cross-domain file in the root directory. For security reasons, the web browser
cannot access data that resides outside the exact web domain where the SWF file originated.
However, Adobe Flash Player can load data across domains if permission is granted from the
server. This is accomplished by including a small crossdomain.xml file on the remote server that
permits Flash to connect to services on that server. See the following code example:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*"/>
</cross-domain-policy>
For additional information, see Using cross-domain policy files in the Adobe Flex 3 Help, Adobe
TechNote "External data not accessible outside a Macromedia Flash movie's domain," or view
a sample cross-domain file.
Deploying crossdomain.xml
To deploy the cross-domain file on ArcGIS Server, see the instructions below specific to your
platform and version. Note the crossdomain file goes on the server with ArcGIS Server, not the
server with your application.
ArcGIS 10.1 comes with the crossdomain.xml already installed, so unless you want to
make changes, it should work successfully.
To deploy the cross-domain file on ArcGIS Spatial Data Server, see the following instructions
specific to your platform and version:
ArcGIS 10.1 Spatial Data Server for the Java Platform installs the client access policy files in the
Java installation directory (for example, C:\Program Files\ArcGIS\SDS10.1\java). Copy the
crossdomain.xml file to your web server's root directory. For example:
If you use Apache Tomcat, place the appropriate client access policy file
in $CATALINA_HOME/webapps/ROOT (Linux) or
%CATALINA_HOME%\webapps\ROOT (Windows) prior to deploying.
If you use IBM WebSphere or Oracle WebLogic, create a .war file that contains the
appropriate client access policy file and deploy it to the web server's root directory.
For ArcGIS 10.1 Spatial Data Server for IIS, install the Cross-domain Policy Files when you run the
installation wizard. This installs the crossdomain.xml file in the web server root location.
Additional information
Please see the crossdomain.xml for additional information specific to crossdomains.
Using crossdomain.xml
In this topic
Deploying crossdomain.xml
Version 3.7
To access data from a different server other than the one hosting your Flex application, the
remote server needs to have a cross-domain file in the root directory. For security reasons, the
web browser cannot access data that resides outside the exact domain where the Shockwave
Flash (SWF) file originated. However, Adobe Flash Player can load data across domains if
permission is granted from the server. This is accomplished by including a small
crossdomain.xml file on the remote server that permits Flash to connect to services on that
server. See the following code example:
Sample crossdomain.xml file
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*"/>
</cross-domain-policy>
Deploying crossdomain.xml
To deploy the cross-domain file on ArcGIS Server, see the instructions specific for your platform
and version.
Debugging tips
Version 3.7
Use the following tips, including Flex code and calls to the server, to debug
your ArcGIS API for Flex application.
Checking the problem view
When compiling your application in Adobe Flash Builder, note the messages on
the Problems tab located below your code.
Using TraceTarget
Use TraceTarget as an alternative to multiple trace() calls. To use TraceTarget,
add <mx:TraceTarget/> to your code, then debug the application in Flash Builder
Copyright 2016 Esri. All rights reserved.
the Console tab, allowing you to listen for traffic between your Flex application
and a server. This is especially helpful when working with a server task (for
example, the geoprocessing task).
See the Adobe site for more information on TraceTarget.
Using the debug version of Flash Player
Ensure you have the debug version of Flash Player installed. Right-click
anywhere in a Flash application and verify that Show Redraw
Regions and debugger appear in the list.
To debug your application, first set breakpoints in your code. The debugger will
stop executing the application at those specific points, and you can then inspect
variables and step through the code one line at a time.
You can also take advantage of the debug functionality in Adobe Flash Builder.
Click the Debug button (to the right of the Run button) or press F11. When in
debug mode, Flash Builder will append ?debug=true to the URL.
For more information, go
tohttp://learn.adobe.com/wiki/display/Flex/3g.+Debug+your+applicationand follow
thetutorial and video links.
Monitoring web traffic
If your application compiles but the maps and tasks are not working, use an
HTTP monitoring tool to watch the interaction with ArcGIS Server tasks and
services and other external requests. For instance, use the HttpFox extension in
Firefox or a cross-browser monitoring tool such as Charles Web Debugging
Proxy.
Note that all communication with ArcGIS Server uses the REST API, so there are
many open-source solutions available to view requests (headers and
Copyright 2016 Esri. All rights reserved.
parameters) and responses. This is especially helpful when working with tasks.
For example, you can take the request from HttpFox or Charles and directly
manipulate the variables in the browser.
When finished debugging, don't forget to close your debugging session by either
closing the browser or pressing the Terminate button in the Console view.
Previous versions
Version 3.7
NIM099505 - Fixed an issue where the Attribute Table didn't show the domain from the feature
type.
NIM102867 - Corrected the problem where binding directions options fails; however, using
action script to create and set direction options succeeds.
NIM101995 - The style specified in the InfoWindow label is now honored in the sample
application.
NIM102756 - Fixed an issue where legend labels did not print. This was handled by including the
Name property for dynamic layers.
Fixed and issue where unable to print image services secured using tokens.
NIM092242 - Can now specify hyperlinks for fields with URLs in the 'Show related records' popup.
GeoEnrichment specific: add default property metadata on intersectingGeographics.
Added refreshInterval property to Layer class. This allows you to specify a refresh interval of
the layer in minutes.
Added support for the refreshInterval property in the WebMapUtil class.
Added the ability to customize map tips when using the Draw tool. Seven properties were added
to the Draw tool to aid in
this: toolTipMultipointEnd,toolTipMultipointStart, toolTipPoint, toolTipPolyContinue, toolTipPol
yEnd,toolTipPolyStart, and toolTipStartAndLetGo.
Exposed AttributeInspector.showFeature to simply display an attribute of a feature.
Discussion forum post- If working with hyperlinks in a custom pop-up desciption, you can specify
a target attribute. By default, if no target is set, the link will open up in a new window or tab.
Bug fixes
Fixed incorrect error message while signing into ArcGIS Portal - GitHub/95.
Fixed an issue where the ExportWebMap geoprocessing task sets default server side selection
color when SelectionColor is set to NaN .
GeoEnrichmentTask.createReport now uses a proxyURL if set.
Fixed an issue where InfoWindow draggable content could not be dragged if it was defined in
MXML.
Added GeoEnrichment capabilities - Using GeoEnrichment, you can get information about the
people, places, and businesses in a specific area or within a certain distance or drive time from a
location. You can also use the GeoEnrichment service to obtain additional geographic context
(for example, the ZIP Code of a location) and geographic boundaries (for example, the geometry
for a drive-time service area). Read more at here and the API Reference
for GeoEnrichmentTask and Infographic. See theGeoEnrichment samples.
IdentityManager support for OAuth when accessing ArcGIS Online for Organizations. One new
class, OAuthInfo, three new methods (findOAuthInfo(), registerOAuthInfos() and signOut() ) and
four new IdentityManager events. (showOAuthLauncher, showOAuthWebView, signIn and
signOut). See the ArcGIS.com Web Map using OAuthsample.
Support for a new locale, Finnish (fi_FI).
New property, EditTool.autoMoveGraphicToTop, that when true (the default) moves selected
graphics to the top of the stack within the parent graphics layer. [See forum post]
If you are using OAuth based on the standalone OAuth sample, you might want to look at taking
advantage of the built-in OAuth workflow available with the new updated IdentityManager.
Bug fixes
NIM093532 - "The legend is not updated in ArcGIS API for Flex application when a renderer is
changed after the map is loaded and a layer is not visible."
The Directions component no longer displays a "Sign in aborted" message under "More info" if
user cancels the sign in window when prompted to log in.
No more glow filter crashes when zooming in quickly on selected lines or polygons.
See https://github.com/Esri/arcgis-viewer-flex/issues/78.
No more MapImageLayer (used by KML Layer or a custom overlay) crashes. [See forum post]
Allow complete refreshing of KML and GeoRSS Layers. [See forum post]
CompositeSymbol: a runtime error was thrown when using CompositeSymbol for polygons and
if the CompositeSymbol included a SimpleMarkerSymbol.
AttachmentInspector: Improve readability of attachment names when multiple attachments.
See https://github.com/Esri/arcgis-viewer-flex/issues/178
Legend support for WMS and ArcGIS Image Server. Simplified LegendSkin. New property:
LegendItemInfo.imageURL for WMS legend URLs. New methods,
ArcGISImageServiceLayer.getLegendInfos() and WMSLayer.getLegendInfos() since these now
implement ILegendSupport interface.
Support for required fields using the new FieldInspector.required property or if it is non-nullable
fields in the service. Support for setting custom renderer for read-only properties.
FieldInspector.rendererIsEditor indicates that the same component is used for both read and
edit scenarios. New method AttributeInspector.validate() to trigger the validation of the form.
New AttributeInspector.isValid property if validation has passed for the form.
Data validation on the client side. Support for data validation when editing attributes using
DoubleField.fractionalDigits property. See the DoubleField.as file in the
/src/com/esri/ags/skins/fieldClasses folder inside the downloaded API zip file.
Date formatting can be customized using CalendarField.dateFormat and useUTC.
The AttributeInspectorSkin now defines the components used for editing of fields. You can take
advantage of the new interface classes to create mobile friendly
skin:ICodedValueDomainField, IDateField, IDoubleField, IFieldRenderer, ILabelField andITypeFiel
d.
New property for CSVLayer to specify the CSVLayer.portalURL, to be used for creating the CSV
layer. Similar to the serviceURL for KMLLayer.
If you have custom skins for AttributeInspector and RelationShipInspector, they will need to be
updated.
Mobile: consider create a customized version of the updated AttributeInspectorSkin using nonmx components to replace DateField and MemoField.
Bug fixes
NIM091075 - Only show the top VGroup of the PopUpRendererSkin if it's not empty. Reported
as "If a title is not defined in the general popup properties, media popups will not display
properly."
NIM092226 - ArcGISLocalTiledLayer wasn't working for TPK created from non-default "Layers"
dataframe name.
NIM089381 - Add option within Edit Widget to adjust date field format, similar to the date field
format within the popup configuration. This takes advantage of the ability to set dateFormat on
the date components used by AttributeInspector.
NIM076665 - More obvious snapping difference between node and vertex snapping.
Improved snapping for nodes on a line.
Relationship inspector bug fixes
DrawTool for multipoint geometries work again.
For non-point data, the SimpleMarkerSymbol and PictureMarkerSymbol now work again inside a
CompositeSymbol.
The long date format for Arabic and Italian displays correctly.
The InfoWindow styles that were added in version 3.1 are now documented:
headerPaddingBottom, headerPaddingLeft, headerPaddingRight and headerPaddingTop.
Direction improvements: updated skin with added user options for optimizing route and return
to start. The routing service URL now defaults to
http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World.
New AttributeTable.exportColumnDelimiter property to support custom CSV delimiters.
New GeocoderLocatorOptions.minScale property, to specify when the search should be based
on the center of current map extent.
New PortalInfo.helperServices property, that includes the default printing service, geocoding
service etc when using an ArcGIS Organization or Portal for ArcGIS.
The default for the doNotLocateOnRestrictedElements property on ClosestFacilityParameters,
RouteParameters and ServiceAreaParameters have changed from false to true.
Updated localization for Hebrew and several other locales.
Better support for Portal for ArcGIS and hosted organizations.
The results of the Geocoder should be better since the map extent (technically, map center and a
distance) is only used when zoomed in past 1:150,000.
Bug fixes
NIM090192 - The geoprocessing widget configured in Flex Viewer 3.2 prompts for credentials
although the geoprocessing service has not been secured.
NIM087793 - Certain WMTS (Web Map Tile Service) layer fails to load with ArcGIS API for Flex.
NIM089743 - Longer field values in a relate are cut off in the popups.
NIM090226 - Directions widget showed "Unknown" image for certain direction types.
NIM090234 - Directions widget showed incorrect images for "Bear left, then right" and "Bear
right, then left" directions.
NIM090362- Show related records for map service layers with ID of 10 or higher not working.
Legend component not honoring scale dependency for ArcGIS 10.0 and earlier map services.
Allow horizontal scrolling in AttributeInspector and its RelationshipInspector.
Updated LegendSkin to prevent runtime errors when parentLayerId is null.
AttributeTable now properly honors column order when columnsOrder="fieldInspector".
AttributeInspector fix for when skin changes.
Directions widget - clicking "Directions" with no search strings removed point markers but not
the line from previous directions.
Support more WMTS services: There is now a certain tolerance for matching scales in LODs that
aren't 100% identical.
Better support for Web maps created using ArcGIS Explorer Online.
The generalization/rounding of the screen coordinates for lines and symbols have been
improved.
Six new locales: Danish, Estonian, Hebrew, Latvian, Lithuanian and Portuguese (Portugal) - for a
total of 22 supported locales.
New Geocoder component - a ready to use component for searching for locations and/or
features. Supports both layers and tables. New related classes: GeocoderEvent,
GeocoderLocatorOptions, GeocoderMapService, GeocoderSearchResult and GeocoderSkin. See
the Geocoder sample.
New Directions (routing) component - a ready to use component for creating driving directions
in your application. You can either type in an address or a feature (see Geocoder above) or click
on the map to add new stops. Adding a destination by clicking on the map will automatically
reverse geocode to get a nice address label. New related classes: DirectionsEvent,
DirectionsGeocoderOptions, DirectionsRouteOptions, DirectionsSkin, DirectionsStop and
DirectionsStopSkin. See the Directions sample.
New CallResponder class that helps manage results for asynchronous calls.
New property AddressToLocationsParameters.sourceCountry to use with the World Geocoding
Service on geocode.arcgis.com.
New property LOD.levelValue to help create correct tile URLs.
New property RouteParameters.directionsOutputType to specify content and verbosity of the
returned directions.
New properties on GeoRSSLayer to set different symbols based on geometry type: pointSymbol,
polylineSymbol and polygonSymbol.
New property showInLegend on Layer and LayerLegendInfo classes.
New property showInLegendHiddenLayers on ArcGISDynamicMapServiceLayer and
ArcGISTiledMapServiceLayer to specify which sublayers should not be shown in the legend.
Automatic attribution (copyrights) that change based on current extent, added for World
Imagery, World Street and Ocean basemap.
WebMapUtil updated to support showLegend, web tiled layers (included WMTS layers
converted to web tiled layers), GeoRSS layers and getting the Bing key from the portal
organization if the bingMapsKey is not set.
Samples
Samples available from GitHub: fork it or just download the zip.
Samples for new components: Geocoder sample and Directions sample.
OAuth sample showing how to sign in to the ArcGIS Platform.
Detailed list of changes to samples since last version:https://github.com/Esri/arcgissamples-flex/issues?labels=verified&milestone=1&state=closed
If you are already using CallResponder, you might have to update your code.
Bug fixes
NIM088718 - Player can crash when a popup is highlighting a line and the user zooms in on the
line. [See forum post and forum post]
NIM089615 - The Flex Viewer Edit widget does not recognize numbers with more than two
decimal places, regardless of the level of precision set on the field
NIM089064 - Editor widget does not display attribute window properly after editing overlapping
features
NIM087717 - AIR application with ArcGISLocalTiledLayer does not show TPKs at larger
scales(such as 1:2500 or 1:1000).
NIM087691 - If wrapAround180 = true and the projection doesn't support wrapAround180, RTE
are thrown because the wrapAround isn't set back to false.
New AttributeTable component - an interactive editable data table for feature layers and tables.
Aside from providing a tabular display of the layer's data, graphics can be selected, deselected,
and zoomed to by interacting with the AttributeTable. If the layer is editable, the feature
attributes will be editable and it will support domains and subtypes as defined by the Feature
Service. New related classes: AttributeTableColumn, AttributeTableEvent and
AttributeTableSkin. See theAttributeTable sample.
Better support for related records using the new RelationshipInspector component. New related
classes: RelationshipInspectorAttributeInspectorSkin, RelationshipInspectorEvent and
RelationshipInspectorSkin. See the Relationship Inspector sample.
MobileArcGISLocalTiled: Support for Esri tile package (.tpk) in mobile applications ArcGISLocalTiledLayer class.
Automatic attribution (copyrights) at bottom right of map. Can be turned off
withMap.attributionVisible. Three new related classes Attribution, AttributionSkin and
IAttributionSupport.
Support for rotating maps. New properties: Map.mapRotation,
Map.middleButtonRotationEnabled, Map.multiTouchRotationEnabled and
Layer.rotatedMapExtent. [NIM051617]. See the Map rotation sample.
InfoWindow (pop-up windows) changes:
InfoWindow auto-anchoring includes right, left, bottom, and top.
InfoWindow now defaults to a RIGHT anchor.
InfoWindow is draggable. This allows you to drag the InfoWindow to see what's under
it, and also dock it to a different side of the feature.
New layer types:
New WebTiledLayer to support adding non-ArcGIS Server map tiles as a layer to the
map. See the new WebTiledLayer sample.
New CSVLayer to support CSV specified by URL. See the new CSV Layer sample.
New GeoRSSLayer to support GeoRSS feeds. See updated GeoRSS sample.
WMTSLayer supports proxyURL properly.
ArcGISTiledMapServiceLayer url property now defaults
tohttp://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer.
Map enhancements
New Map.zoomTo() method easily zoom to a feature.
New center property to easily center map. Use this with the level property to start the
map at a specific center and level.
The default cyan highlight color for the graphic of the current popup window can be
changed using the new Map.infoWindowRendererHighlightColor style on the Map
component. Set to NaN to not highlight the selected feature. [NIM073051]
Support for CSV by reference layers found in web maps.
Ability to retrieve distinct values from a layer using the Query.returnDistinctValues property. Requires,
at a minimum, ArcGIS 10.1 sp1, and a service that has been published with support for advanced
queries.
Symbol changes:
Support for wraparound for custom symbols. Developers can
useSymbol.getWrapAroundGeometries() in the draw function of their custom symbol to
retrieve the geometry on multiple worlds, and then proceed as before. [NIM064744]
Improved performance for most symbols.
New MapMouseEvent.originalTarget property makes it easier to find out the orginal target (e.g. which
layer) was clicked. [forum post]
Additional styles for the ContentNavigator: headerPaddingBottom, headerPaddingLeft,
headerPaddingRight and headerPaddingTop.
New DrawEvent drawUpdate event on the DrawTool that is fired while drawing, and when the geometry
of the feature is updated. This is useful if you want to display dynamic measurements while a feature is
being drawn.
FeatureLayer changes:
FeatureLayer: Clear the existing selection when added to a Map if the Map's spatial
reference is different than the spatial reference of the layer.
FeatureLayer: Set the selectionColor to NaN to turn off the highlight ("selectionColor").
New FeatureLayer.selectionSymbol property to use a symbol instead of, or in addition
to, the default behavior of highlighting the selected features with a glow using
selectionColor. [NIM073051]
New FeatureLayer queryLimitExceeded event that is dispatched when the feature layer
query hit the maxRecordCount limitation. Requires ArcGIS 10.1 or later.
Samples
All samples have been updated with more comments and description.
Samples have been updated to use the locator
service:http://geocode.arcgis.com/ArcGIS/rest/services/World/GeocodeServer.
Mobile samples have been updated to work better on different type of devices.
New samples
Add new workflows to an application with a tabular view of your data - The new
AttributeTable component can provide new ways to allow your users to interact
with data to view and edit information.
Display pop-ups interactively - This sample shows one approach to provide
programmatic access to display information in pop-up windows or by clicking on
the map.
Weighted Heatmaps - Configure heat maps using functions to control density
radius of the heatmap and index colors from the heatmap gradient used with its
color palette.
View features with related records - Use the new RelationshipInspector
component to display/inspect features that have related records.
ArcGISDynamicMapServiceLayer.copyright, ArcGISImageServiceLayer.copyright,
ArcGISTiledMapServiceLayer.copyright and WMTSLayer.copyright.
The ownershipBasedAccessControlForFeatures property on FeatureLayerDetails is now
inherited from LayerDetails.ownershipBasedAccessControlForFeatures.
The ownershipBasedAccessControlForFeatures property on FeatureTableDetails is now
inherited from TableDetails.ownershipBasedAccessControlForFeatures.
Bug fixes
Identify operation on pre-10.1 servers was sometime ignoring the spatial reference.
Swatches for non-solid lines were not honoring color, alpha and width (but the actual feature
rendering was still correct).[NIM081300]
On mobile devices InfoWindow was flickering when panning.
The SignInWindow is more mobile and tablet friendly. [NIM085020]
Connect to ArcGIS Online and Portal for ArcGIS by taking advantage of the ArcGIS Portal API.
Requires Adobe Flex 4.6 SDK or higher, which in turn requires at least Flash Player 11.1.
Enhancements
Since 2.5, 63 new classes, 138 properties on existing classes, and 57 methods on existing classes
have been added to support new API functionality and support for ArcGIS 10.1 functionality,
ArcGIS Online, and Portal for ArcGIS.
Using panEasingFactor in mobile samples for better panning on mobile devices.
Changes
The webmap package has been renamed to portal and includes new class for connecting to
ArcGIS Online and Portal for ArcGIS.
The arcgisSharingURL property in WebMapUtil has been renamed to portalURL .
The default value for Map.openHandCursorVisible has changed from true to false.
On the GeometryServicethe input parameter for the project() method is now projectParameters
instead of geometries. This also allows for specifying datum transformations [requires ArcGIS
Server 10.1].
On the Locator the input parameter for the addressToLocation() method is now
addressToLocationParameters instead of address, outfields. This also adds support for batch
geocoding and searching within an extent [requires ArcGIS Server 10.1].
Bug fixes
Requires Adobe Flex 4.5 SDK or higher, which in turn requires at least Flash Player 10.2.
Support for new ArcGIS for Server 10.1 capabilities
Change renderers or layer order in map services (dynamic layers).
Add layers on the fly in map services (dynamic workspaces).
Generate data classifications on the server for layers in map services.
Use enhanced query options to order results and generate statistics.
Rollback a group of edits if one of them fails.
Editor tracking in feature services.
Use the new PrintTask to generate printable output on the server.
z/m value support in map and feature services.
Geodatabase versions.
Cancel geoprocessing jobs.
An IdentityManager that automatically prompts the end user for logging in to secure ArcGIS Server.
The pop-up window displays with multiple features (using the ContentNavigator class).
When drawing freehand lines or polygons, the point interval (and thus the number of vertices) can be
adjusted.
KML layer supports refresh and httpquery.
Better locale support for VETiledLayer (Bing Maps).
Enhancements
The toJSON() and fromJSON() methods work with objects, not strings.
The Domain class is now an interface and has been renamed to IDomain.
The JSON class has been renamed JSONUtil, which is the same naming convention as for all the
other classes in the utils package, and it also prevents collision with the JSON class added in
Adobe Flash Player 11.
The Renderer class implements the new IRenderer interface.
The id property in LayerInfo has been renamed to layerId.
The attribute , attribute2 , attribute3 , and attributeDelimiter properties that were
deprecated at 2.5 have been removed at 3.0. Use field , field2 , field3 ,
and fieldDelimiter instead.
The default value for the UniqueValueRenderer.fieldDelimiter (formerly
UniqueValueRenderer.attributeDelimiter) have changed from "" to ",".
The attribute property on the ClassBreaksRenderer class has been renamed to field .
The defaultVisibleLayers() method has been removed. Setting the visibleLayers property on
ArcGISDynamicMapServiceLayer and ArcIMSMapServiceLayer to null will achieve the same
result.
Removed the following deprecated properties: ArcGISTiledMapServiceLayer.visibleLayers,
VEAddress.postalTown, VEGeocodeResult.calculationMethod, and
VEGeocodeResult.matchCodes.
Removed the following deprecated methods: FeatureSet.convertToJSON(),
FeatureSet.convertFromJSON(), and NavigationToolzoomToFullExtent().
Removed the following deprecated event: AttachmentInspector result event.
Removed the unit property from the Map and Layer classes. This is now automatically inferred
from the spatial reference.
The default value for the visibleLayers property on ArcGISDynamicMapServiceLayer and
ArcIMSMapServiceLayer have changed to null. Previously they defaulted to the visible layers as
defined by the default visibility in LayerInfo.
The ClassBreaksRenderer has a new property, isMaxInclusive , that defaults to true to align
with ArcGIS for Server, which is always inclusive. Previously, the behavior was to not be
inclusive.
Caution:
If you're upgrading an application from version 2.5 to 3.x, be sure to readMigrating from 2.5 to
3.x.
For most functionality (for example, basic mapping and query), ArcGIS Server 9.3 or later is
more than adequate. For editing, time-aware layers, closest facility, and service area, the ArcGIS
API for Flex 2.0 (or later) and ArcGIS Server 10.0 (or later) are required. For PrintTask,
dynamic layers, and dynamic workspaces, the ArcGIS API 3.0 for Flex (or later) and ArcGIS for
Server 10.1 (or later) are required. Seesystem requirements for more details.
Previous versions
See What was new in 2.x and What was new in 1.x.
Requirements
Version 3.7
This topic contains the following information to successfully migrate from 2.5 to 3.0:
Requirements
Upgrading your Flex API application code from 2.5 to 3.0
Requirements
The following requirements have changed at 3.0:
Adobe Flex SDK 4.6 or later
As of version 3.0 of the ArcGIS API for Flex, the minimum Adobe Flex software development
kit (SDK) version is 4.6. For earlier versions, 2.x will work with any Adobe Flex SDK 4.0 or
later, while 1.x will work with Adobe Flex SDK 3.x.
Flash Player 11.1 or later
As part of the move to Flex 4.6 SDK, Flash Player 11.1 or later is now required.
The following sections explain the changes you need to make to convert from ArcGIS API 2.5
for Flex to ArcGIS API 3.0 for Flex:
Project property changes
The webmap package has been renamed portal and includes new classes for connecting to
ArcGIS Online and Portal for ArcGIS.
The Domain class is now an interface and has been renamed IDomain.
The JSON class has been renamed JSONUtil, which is the same naming convention as all the
other classes in the utils package.
The id property in LayerInfo has been renamed layerId.
The attribute , attribute2 , attribute3 , and attributeDelimiter properties
forUniqueValueRenderer that were deprecated at 2.5 have been removed at 3.0;
use field , field2 , field3 , and fieldDelimiter instead.
The attribute property on the ClassBreaksRenderer class has been renamed field .
The href property on the MapImage class has been renamed source .
The arcgisSharingURL property on the WebMapUtil class has been renamed portalURL .
The AttributeInspector form has been sparkified, which includes the following changes:
New AttributeInspectorRenderer in the skins
FieldInspector.renderer is now FieldInspector.editor
FormData is now FormField
New event: FormFieldEvent
The formItemsOrder property on the AttributeInspector class has been
renamed formFieldsOrder .
The fromJSON() and toJSON() methods on FeatureSet take an object instead of a string.
Other changes
The default value for Map.openHandCursorVisible has changed from true to false.
On the GeometryService, the input parameter for the project() method is now
projectParameters instead of geometries. This also allows for specifying datum transformations
(requires ArcGIS 10.1 for Server).
On the Locator, the input parameter for the addressToLocation() method is now
addressToLocationParameters instead of address, outfields. This also adds support for batch
geocoding and searching within an extent (requires ArcGIS 10.1 for Server).
The ClassBreaksRenderer has a new property, isMaxInclusive , that defaults to true to align
with ArcGIS for Server, which is always inclusive. Previously, the behavior was not inclusive. If
you were using ClassBreaksRenderer and taking advantage of the earlier behavior, you now
need to set it to false.
The layerDefinitions property on ArcGISDynamicMapServiceLayer, FindParameters, and
IdentifyParameters can now take LayerDefinition in addition to a string. When using MXML, only
LayerDefinition is allowed. When using ActionScript, both are allowed.
The default value for the UniqueValueRenderer.fieldDelimiter (formerly
UniqueValueRenderer.attributeDelimiter) has changed from "" (empty string) to "," (comma)
and "" is no longer a valid value.
The TextSymbol constructor now takes an alpha value as its fourth parameter. If you were using
the TextSymbol constructor with more than three parameters, you need to adjust accordingly.
The default for the visibleLayers property on ArcGISDynamicMapServiceLayer and
ArcIMSMapServiceLayer changed to null.
The units property in Map and Layer has been removed as it is no longer needed; instead, this
information is inferred from the spatial reference.
The visibleLayers property on ArcGISTiledMapServiceLayer has been removed.
The autoMoveToTop property on Graphic has been removed.
The postalTown property on VEAddress has been removed.
The calculationMethod and matchCodes properties on VEGeocodeResult have been removed.
The defaultVisibleLayers() method
on ArcGISDynamicMapServiceLayer andArcIMSMapServiceLayer has been removed.
The convertFromJSON() and convertToJSON() methods on FeatureSet were deprecated at
2.4 and have been removed at 3.0. Use toJSON() and fromJSON() instead.
The zoomToFullExtent() method on NavigationTool was deprecated at 2.3 and has been
removed at 3.0. Use Map.zoomToInitialExtent() instead.
The result event on AttachmentInspector was deprecated at 2.4 and has been removed at 3.0.
Use the event types defined in AttachmentEvent instead.
Requirements
Version 3.7
This topic contains the following information to successfully migrate from 1.3 to 2.0:
Requirements
Upgrading your Flex API application code from 1.3 to 2.0
Upgrading your Adobe Flex 3 SDK code to Flex 4 SDK
Requirements
The following requirements have changed at 2.0:
Flash Player 10
Adobe Flash Builder 4 is very similar to Flex Builder 3, and you should feel right at home from
the beginning.
Copyright 2016 Esri. All rights reserved.
For a basic application, the only migration step is to specify the theme. In Adobe Flash Builder 4,
there is an option for "component set" where you can choose either MX+Spark (the default) or
MX only. To specifically set existing applications to use the "old" Halo theme, add the following
compiler arguments to Project Properties > Flex Compiler:
-theme=${flexlib}/themes/Halo/halo.swc
While it's possible to continue to use Flex Builder 3 if you add Flex 4 SDK support, the
documentation in this Help system assumes you're using Adobe Flash Builder 4 or later.
Similarly, while there are other integrated development environments (IDEs) you can use, the
documentation herein assumes you're using Flash Builder.
The following sections explain the changes you need to make to convert from ArcGIS API for
Flex 1.3 to ArcGIS API for Flex 2.0:
Connecting to ArcGIS Server 9.3.x
If you're connecting to an ArcGIS 9.3.x server (as opposed to 10 or later), you might have to
adjust your code as follows, but everything else should work just fine.
For Query and Geoprocessor, add useAMF="false" since AMF is now the default output format,
and older servers do not support AMF.
For ArcGISImageServiceLayer, if you're not already specifying imageFormat, add
imageFormat="png" since "jpgpng" is now the default output format, and older servers do not
support this image format.
Change barriers to pointBarriers.
Change returnBarriers to returnPointBarriers.
Change RouteSolveResult.barriers to RouteSolveResult.pointBarriers
Change the required Flash player version to 10 or higher. Otherwise you might get the following
error: "1046: Type was not found or was not a compile-time constant: Matrix3D."
Change the SDK version to Flex 4. Otherwise you might get the following error: "1046: Type
was not found or was not a compile-time constant: SolidColorStroke."
Package changes
The easiest way to update the import statements in your code to use the new package stcture is to
open your code in Flash Builder 4, set the project to use the Flex 4 SDK and the 2.0 version of
the Flex API, then fix each error as it occurs. One way to do this is to go to the problem line by
double-clicking an error, such as "1046: Type was not found or was not a compile-time constant:
FeatureSet.", put the cursor at the end of "FeatureSet", and press CTRL-SPACE. Flash Builder
will then add the missing import statement and organize all your import statements as well. The
following is a more extensive list, but again, the easiest way is to take advantage of the IDE and
step through the errors.
Name changes
The Draw and Navigation tools have been renamed to DrawTool and NavigationTool,
respectively.
The arealengthsComplete event in GeometryService has been renamed to
areasAndLengthsComplete.
The arealengths property in GeometryServiceEvent has been renamed to
areasAndLengthsComplete.
GPDateUtil has been renamed DateUtil, since dates aren't specific to just the geoprocessor. The
class has moved from com.esri.ags.tasks to com.esri.ags.util for the same reason.
Geoprocessor.outSpatialReference is the new name for the
Geoprocessor.outputSpatialReference property. This makes it consistent with the other "out"
SpatialReference properties.
The getLayerDetails() methods on ArcGISDynamicMapServiceLayer and
ArcGISTiledMapServiceLayer have been renamed to getDetails(). They also have a new
additional method called getAllDetails().
All BufferParameters.UNIT_* constants have been renamed to GeometryService.UNIT_*, since
they've moved to the GeometryService class.
Change BaseTask.sendURLVariable was changed to BaseTask.sendURLVariables (it's now plural).
Routing now also supports line and polygon barriers. Consequently, the barriers properties on
RouteParameters and RouteSolveResult have been renamed pointBarriers, and the
returnBarriers property on RouteParameters has been renamed returnPointBarriers.
Constructor changes
Replace the "features" property with "geometries", and make sure you update the value from
an array of features to an array of geometries.
The Extent.contains() method now takes any geometry, combining and expanding the
functionality of the old contains(point) and containsExtent(extent) methods.
The Navigation and Scalebar classes have been "sparkified" to take advantage of new Flex 4
functionality. You can now change the full skin parts instead of just some CSS settings. As part of
this, four classes (NavigationEvent, NavigationMinusButton, NavigationPlusButton, and
NavigationSlider) have been removed and replaced with three skins (NavigationSkin,
NavigationZoomInButtonSkin, and NavigationZoomOutButtonSkin).
Since FeatureLayer now supports selections, there is less reason to perform selections yourself
using the Extent.contains() method.
Inputs for GeometryService are now geometries instead of graphics. See the following code
example:
//1.3:
//1.3:
In the response from a buffer operation, the GeometryServiceEvent now returns "result" instead
of "graphics". In the case of a buffer operation, the actual geometries are now returned instead
of an array of graphics as shown in the following code example:
//1.3:
The parameterValues property in ExecuteResult has been renamed to "results". It still returns an
array of ParameterValue.
If you're using graphics with PictureMarkerSymbol and listening to events such as a mouse click,
the target is now a custom sprite. In 1.3, the target was a graphic. For more information see
the Adobe help page on event propagation.
The following sections show the steps to migrate Flex 3 code to Flex 4.
Make it work with Flex 4 SDK
Replace mx:Application with s:Application, and set the namespaces as shown in the following
code example:
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"
<s:layout>
<s:VerticalLayout/>
</s:layout>
Read up on Flex 4 and learn more about Spark components, new layouts, skinning, and styling
possibilities.
Version 3.7
Legacy:
This topic refers to the 2.x versions (2010-2011). For 3.x, see What's New in
ArcGIS API for Flex.
Caution:
Editing:
Ability to turn on snapping programatically (without the user pressing the Ctrl-key)
Enhancements for editing workflows: Map Service will automatically refresh when a
matching feature layer in selection mode is edited
AttachmentInspector supports tables
Support hosted services on ArcGIS.com
More spark support for Mobile development
New WMTSLayerto support WMTS layers
Improved for ArcGIS.com web maps: popups defined by reference are supported; popups are ignored
when using ignorePopups for tiled and dynamic layers (earlier only feature layers were supported)
Improved KML support
Legend component listens to changes in map layers.
Flare symbol for clusters shows actual symbol of the individual features.
Improved scalebar for Arabic and other right-to-left (RTL) languages
getLegendInfos() now looks for defaultSymbol on UniqueValue and Classbreak renderers
Bug fixes
WMS:
Attachment sizes are calculated based on 1,024 bytes in a kilobyte. [NIM070101 AttchmentInspector shows incorrect size of the attachment]
Dates in AttributeInspector can be typed (in addition to using the DatePicker).
Setting dates to null in AttributeInspector works. [NIM070754 - The date field cannot be set to
null after choosing a date from the Date Picker]
Deleting features doesn't send duplicate delete request. [NIM070636 - 2 requests are created
for delete operation in Editor sample]
Bug fixes
Adding vertices to lines and polygons in projections other than geographic and Web Mercator
works as in 2.2 and earlier. This did not work properly in the 2.3 release.
Snapping works for all projections. In version 2.3, snapping only worked with Web Mercator and
geographic projections.
The following functionality, enhancements, changes, and bug fixes are new at version 2.3 which
was released in April 2011:
Functionality
InfoWindow has been rewritten using Spark and moved from the components package to
the com.esri.ags.components.supportClasses package. It has its own skin, and it's easier to
create your own skins for InfoWindow.
Faster zoom performance when the map contains lots of visible dynamic or graphic layers.
Two more detailed levels for Microsoft Bing Maps with scales of 1:564 and 1:282.
The SpatialReference property on WMSLayer.spatialReference can be set (it's no longer readonly). [Ref: forum post]
Scaling of "extent" graphics. [Ref: forum post]
The Editor remembers the last used geometry tool.
The Editor component supports both polygons and polylines in the same cut operation.
[Ref: forum post]
The zoomToFullExtent method in the NavigationTool class has been deprecated. Use the new
method in the Map class, zoomToInitialExtent, instead.
Use name of layers (if available) in the TemplatePicker.
Bug fixes
For a more visual introduction, see the What's New in ArcGIS API for Flex Technical Workshop
video from the 2011 Developer Summit.
The Legend component allows you to easily create a legend for the layers in the map.
Support for arcgis.com Web Maps: WebMapUtil and WebMapEvent.
Undo/redo support while editing with the Editor component.
The Total query count property is available when using ArcGIS Server 10.0 Service Pack 1.
A version property for ArcGISImageServiceLayer, ArcGISTiledMapServiceLayer,
ArcGISDynamicMapServiceLayer, LayerDetails, and TableDetails.
The useMapTime property adds the option for turning off time awareness of a FeatureLayer,
ArcGISDynamicMapServiceLayer, or ArcGISImageServiceLayer. This is convenient when the map
is time aware, but only certain layers should be time aware.
The minScale and maxScale properties were added to LayerInfo.
The excludeDataAtTrailingThumb and excludeDataAtLeadingThumb properties were added
to TimeSlider.
Do not reuse the last image when service is turned back on and the sublayers have changed.
[Ref: forum post]
Setting attributes to null when editing are sent to the server. [Ref: forum post]
Zoom to tall extents on tall maps works. [Ref: forum post]
Map and Navigation handle null levels of detail (LOD) better, improving support for toggling
between dynamic and tiled maps. [Ref: forum post]
Time-aware feature layers with both start time and end time fields filter the features correctly
according to the map's timeExtent. [Ref: forum post]
QueryTask.executeRelationshipQuery() returns fields or fieldAliases on the returned
FeatureSets.
New classes:
WMSLayer and WMSLayerInfo support WMS layers. Both classes work with 1.1.0, 1.1.1,
and 1.3.0 WMS servers.
WebMercatorExtent and WebMercatorMapPoint make it easier to specify latlong-based
extents and points for use with Web Mercator maps.
TextField handles long string attribute values in the AttributeInspector component.
New method:
BaseTask.sendURLVariables() supports extending BaseTask.
New properties:
The Method property on BaseTask forces requests to use POST.
Support for drawing circles and ellipses with DrawTool, including two new constants:
DrawTool.CIRCLE and DrawTool.ELLIPSE.
Support for rotating and scaling features, including two new EditTool constants
(EditTool.ROTATE and EditTool.SCALE), six new events for the EditTool (graphicRotate,
graphicRotateStart, graphicRotateStop, graphicScale, graphicScaleStart, and
graphicScaleStop) and their matching EditEvent constants(EditEvent.GRAPHIC_ROTATE,
EditEvent.GRAPHIC_ROTATE_START, EditEvent.GRAPHIC_ROTATE_STOP,
EditEvent.GRAPHIC_SCALE, EditEvent.GRAPHIC_SCALE_START, and
EditEvent.GRAPHIC_SCALE_STOP).
Support for new MapMouseDown event on Map, including a new
constant:MapMouseEvent.MAP_MOUSE_DOWN.
doNotLocateOnRestrictedElements
on ClosestFacilityParameters andServiceAreaParameters.
AttributeInspector.singleToMultilineThreshold.
AttributeInspector.deleteButtonVisible.
minValue and maxValue on DoubleField handle double precision attribute values in the
AttributeInspector component.
deleteEnabled on AttachmentInspector component and Editor component.
Colors can be specified as VGA color names in addition to hexadecimal formats. The available color
names are Aqua, Black, Blue, Fuchsia, Gray, Green, Lime, Maroon, Navy, Olive, Purple, Red, Silver, Teal,
White, and Yellow. You can use these VGA color name formats in both style sheet definitions and inline
style declarations. The VGA color names are not case sensitive. In the Flex API, this applies to
SimpleFillSymbol.color, SimpleMarkerSymbol.color, LineSymbol.color, TextSymbol.color,
SimpleClusterSymbol.color, TimeClassBreakInfo.color, and FeatureLayer.selectionColor.
Improved support for touch events to make it easier to use on Android phones and other touch-enabled
devices that support Flash Player 10 or above. The Flex API supports drag to pan, double tap to zoom in,
pinch open to zoom in, pinch close to zoom out, and two-finger tap to zoom out. (The latter three only
work with Flash Player 10.1 or above.)
Changes
Bing requests use Microsoft's new REST API. The postalTown property in the VEAddress class as
well as the calculationMethod and matchCodes properties in the VEGeocodeResult class have all
been deprecated since Microsoft no longer returns them.
FeatureLayer is a new type of client-side operational layer that can be created and added to a
map. FeatureLayer extends GraphicLayer and works against an individual layer or table in a
MapService or FeatureService.
Feature layers support the following out-of-the-box functionality:
Query related tablesTake advantage of built-in support for relations between layers and
tables.
At 10.0, a new service, FeatureService, was added to support template-style editing. Several
components have been added to support editing including the Editor component, a configurable
out-of-the-box editing solution.
Additional classes that support editing are as follows:
Support has been added for time-aware layers and a new TimeSlider component. You can query
or display time-aware layers using a particular slice of time. The TimeSlider provides an easy
way to visualize temporal data. For more information, see Time-aware layers.
Localization
The API has built-in support for six languages: Chinese, English, French, German, Japanese, and
Spanish. For more information, see Localization.
Other updates
Bing Maps
Bing Maps (formerly Microsoft Virtual Earth) authentication uses a "key" property instead of
token, client, and server. There is no longer any need for the Virtual Earth Token page.
The Bing Maps environment property has been removed, since Microsoft no longer supports a
staging environment.
Geometry service
Twelve new operations were added to the GeometryService: Autocomplete, Convex Hull, Cut,
Densify, Difference, Distance, Generalize, Intersect, Offset, Reshape, Trim/Extend, and Union.
The Lengths operation supports units and geodesic distances.
The Areas and Lengths operation supports lengthUnit, areaUnit, and geodesic parameters.
Query enhancements to query for all IDs, which can then be used to include paging in
applications.
Query performance has been improved by adding support for faster JSON and by using AMF
(see the AMF section below).
Support for stand-alone tables.
Ability to expose and query relationships.
The identify and find operations support layer definitions.
A new event, isInScaleRangeChange in the Layer class, is fired when the layer's isInScaleRange
property changes.
AMF
AMF (ActionScript Message Format) has been added in ArcGIS Server 10.0 for faster queries.
AMF is currently supported on FeatureLayer, QueryTask, and Geoprocessor. To connect to a 9.3
server QueryTask or Geoprocessor, you need to set the useAMF property to false.
Geocode updates
Locator supports outSpatialReference when connecting to ArcGIS Server 10.0 and above.
Network Analyst updates
The API reference is now available in Flash Builder, both as ToolTips and on the ASDoc tab.
The Adobe Flex 4 SDK is required for API development, which means that Adobe Flash Player 10
or above is the required version for browser applications.
TextSymbol uses Flash Player 10 Text Engine, which means that alpha and angle also work for
non-embedded (device) fonts.
Introduction to Flex
Version 3.7
Flex is designed for developers who want to get a working web-based mapping
application up and running very quickly without spending a significant amount of
time developing code. With the ArcGIS API for Flex, users can develop custom
applications by integrating ArcGIS Server maps and web services inside Adobe
Flash Builder.
The following topics introduce the basics of Flex to help you begin working with
theArcGIS API for Flex:
Discover the building blocks of Flex in Flex events and Flex components.
Version 3.7
Flex applications are developed using the MXML and ActionScript languages with the
ActionScript class library, which contains components, manager classes, data service classes,
and classes for all other features.
Learn more about developing with Flex
MXML can be compared to HTML (tags that lay out the page), and ActionScript can be
compared to JavaScript (the coding). In theory, you could write everything as ActionScript code
(add a button here, put the map at the bottom of the page, and so on), but this is neither practical
nor maintainable.
ActionScript 3 syntax is similar to other languages such as C, C#, C++, and Java. ActionScript is
an object-oriented procedural programming language and includes Java object-oriented features,
such as extending classes and implementing interfaces.
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function onMapLoad():void
{
Alert.show('Hola Mundo');
}
]]>
</mx:Script>
include "myextracode.as";
Note:
Multiple steps take place behind the scenes when Flex compiles your application. The
application is parsed by MXMLC, translated into an ActionScript file, and compiled into a SWF
file.
To better understand how Flex converts MXML tags into code, you can view the interim
ActionScript files. These are deleted unless you specify the "...keep-generated-actionscript"
option when compiling your application.
Flex events
In this topic
Version 3.7
Flex events are generated when a change, such as user interaction (for example,
click), network traffic (for example, sending and receiving data), or component
modification (for example, resizing), occurs in the application.
An event listener, or handler, allows you to detect when these events occur and
tell the Flex application how to respond.
or MXML:
<esri:Map id="myMap" click="onClickFunction(event)">
The ArcGIS API for Flex adds specific events for map, navigation, and tasks,
which are located in the com.esri.ags.events package.
Description
Represents event objects specific to FeatureLayer attachment operations. [New in
AttachmentEvent
version 2.0]
DrawEvent
Represents event objects specific to DrawTool.
EditEvent
Represents event objects specific to EditTool. [New in version 2.0]
ExtentEvent
Represents event objects specific to map extent changes.
FeatureLayerEvent Represents event objects specific to FeatureLayer. [New in version 2.0]
FlareEvent
Represents event objects specific to the Flare symbol.
FlareMouseEvent Represents event objects specific to the Flare symbol.
GraphicEvent
Represents event objects specific to graphics.
GraphicsLayerEvent Represents event objects specific to GraphicsLayer. [New in version 2.0]
LayerEvent
Represents event objects specific to a layer.
MapEvent
Represents event objects specific to the map.
MapImageEvent
Represents event objects specific to ArcGISDynamicMapServiceLayer.
MapMouseEvent
Represents event objects specific to map mouse events. [New in version 1.1]
NavigationEvent
Represents event objects specific to the navigation component.
PanEvent
Represents event objects specific to panning the map.
TimeExtentEvent Represents event objects specific to time extent changes. [New in version 2.0]
ZoomEvent
Represents event objects specific to the zooming (changing scale) of the map.
Description
Represents event objects specific to the AttributeInspector. [New in version
3.0]
Represents event objects specific to ClosestFacilityTask. [New in version
2.0]
Represents event objects specific to DetailsTask. [New in version 2.0]
Represents event objects specific to FindTask.
Represents event objects specific to FindTask. [New in version 3.0]
Represents event objects that are specific to GenerateRendererTask. [New
GenerateRendererEvent
in version 3.0]
GeometryServiceEvent
Event dispatched when an AttributeInspectorFormField is updated.
GeoprocessorEvent
Represents event objects specific to Geoprocessor task.
IdentifyEvent
Represents event objects specific to IdentifyTask.
Represents event objects that are specific to IdentityManager. [New in
IdentityManagerEvent
version 3.0]
Represents event objects that are specific to ImageServiceIdentifyTask.
ImageServiceIdentifyEvent
[New in version 3.0]
Bubbling event dispatched usually from an info container's content to
InfoPlacementEvent
reposition the container around its anchor location based on the value of the
event infoPlacement property. [New in version 3.0]
Represents event objects that are specific to JSONTask. [New in version
JSONEvent
3.0]
LocatorEvent
Represents event objects specific to Locator tasks.
PortalEvent
Represents event objects that are specific to the portal. [New in version 3.0]
QueryEvent
Represents event objects specific to QueryTask.
RouteEvent
Represents event objects specific to RouteTask. [New in version 1.2]
ServiceAreaEvent
Represents event objects specific to ServiceAreaTask. [New in version 2.0]
Represents event objects that are specific to TemplatePicker. [New in
TemplatePickerEvent
version 3.0]
Represents event objects that are specific to WebMapUtil. [New in version
WebMapEvent
3.0]
For more information about handling events in your Flex applications, see the Flex 3 Getting
Started Guide Wiki article Handling Events.
DetailsEvent
FindEvent
FormFieldEvent
Flex components
In this topic
Components
Containers
Version 3.7
The ArcGIS API for Flex provides built-in MXML visual components and containers.
Components
Components, sometimes referred to as controls, are interface widgets that can be added to your
application. Apache Flex components include Button, Label, Form, and TextInput. ArcGIS API
for Flex components include ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer,
and ArcIMSMapServiceLayer.
Tip:
MXML is typically used for layout purposes; however, you can also use ActionScript 3.0 to create and
modify components. To see Flex components in action, check out the Tour de Flex application.
Containers
Containers are layout tools that position the interface widgets or data in the application. Some
example Apache Flex containers are Application, HGroup, VGroup, and BorderContainer;
the ArcGIS API for Flex container is Map.
Containers provide a hierarchical structure that allows you to control the layout characteristics of
child components. Components defined within a container are called children. At the root of any
Flex application is a single container: the Application container.
More information
Version 3.7
Flex is an event-driven programming model. All Flex components undergo the same
instantiation life cycle during which Flex automatically calls component methods, dispatches
events, and makes the component visible.
Knowing the details of this life cycle will help you understand the sequence of events, which
allows you to listen and wait for the proper events.
Note:
After all components are created and drawn, the Application object dispatches an
applicationComplete event. This is the last event dispatched during application startup.
preinitializeAn event dispatched before initialization takes place. When Flex dispatches the
preinitialize event, the children of a component, including internal children, have not yet been
created. It is only useful in rare situations when you must set properties on a parent before the
children are created.
childAddDispatched on the parent container after all children have been initialized but before
the component has been sized and processed for layout.
initializeAn event dispatched to alert initialization. At this time, all the component's children
have been initialized, but the component has not been fully processed or sized for layout.
creationCompleteSignals that the object is complete. This is called after Flex sets the visible
property to true. The component has been sized and processed for layout and all properties are
set. This event is dispatched only once.
updateCompleteFlex dispatches additional updateComplete events whenever the position,
size, or other visual characteristic of the component changes and the component has been
updated for display.
loadSpecific to the ArcGIS API for Flex. This applies to Map and Layer and, consequently,
GraphicsLayer, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer,
ArcGISImageServiceLayer, and ArcIMSMapServiceLayer events. It is dispatched after its
properties are set up but before the map is downloaded and displayed.
Tip:
When working with maps and layers, use the load event in the ArcGIS API for Flexinstead of the
generic creationComplete event. This will ensure that map properties, such as extent and
spatialReference, are available.
More information
For further information about the Flex life cycle, see the following:
There is a known-limit when working with pop-up windows in mobile applications created with
version 3.1. If doing so, please note that you will need to either: Add
both mx.swc and sparkskins.swc to your project, or update PopUpRendererSkin and remove
references to the RelationshipInspector .
Caution:
If working with version 3.4 or above, you will come across errors unless you implement one of
the following two options:
1. Add both the following libraries to the build library
path: ${PROJECT_FRAMEWORKS}/libs/mx/mx.swc and ${PROJECT_FRAMEWORKS}/libs/sparkskins.sw
c
2. Or, if you do not wish to go with the first option, you will need to a modify
the AttributeInspectorSkin so that it no longer references CalendarField and the MemoField .
Please see the snippet below demonstrating this.
AttributeInspectorSkin using a TextField instead of CalendarField and MemoField.
<fx:Component id="dateField">
<!--<fieldClasses:CalendarField dateFormat="shortDate" useUTC="false"/>-->
<fieldClasses:TextField minWidth="200"/>
</fx:Component>
<fx:Component id="memoField">
<!--<fieldClasses:MemoField minWidth="200"/>-->
<fieldClasses:TextField minWidth="200"/>
</fx:Component>
After modifying this skin, you will also need to override two styles in defaults.css . This file
must be in the root of the src folder.
Modified defaults.css file that references the customized AttributeInspectorSkin.
@namespace esri "http://www.esri.com/2008/ags";
esri|AttributeInspector, esri|RelationshipInspector #attributeInspector
{
skinClass: ClassReference("skins.AttributeInspectorSkin");
}
API Diagram
Version 3.7
The following diagram shows the logical grouping of all the classes and
packages in the ArcGIS API for Flex. You can also download a PDF version.
Localization
In this topic
Version 3.7
To compile with the specific locale or locales, take the following steps in Flash Builder:
1. Go to Project > Properties > Flex Compiler.
Adobe 4.6.0 supports 16 locales out of the box (see your Flash Builder install, for
example, C:\Program Files (x86)\Adobe\Adobe Flash Builder
4.6\sdks\4.6.0\frameworks\locale ), while Apache Flex 4.10.0 supports 23 different locales.
This still leaves seven locales supported by Esri that are not supported by the underlying Flex
SDKs. If you you want to add support for a locale not supported by your SDK, please follow the
steps below.
Create the supporting Adobe or Apache Flex SDK files
1. Go to the command prompt on Windows > Start Menu > Run > then type cmd .
2. Type the path to your Flash Builder SDK directory, (for example, cd "C:\Program Files
(x86)\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\bin" ) and press Return.
3. Type copylocale en_us ar . This will create an ar folder with a supporting frameworks file
(most likely in C:\Program Files (x86)\Adobe\Adobe Flash Builder
4.6\sdks\4.6.0\frameworks\locale ).
Tip:
If the above step doesnt create a folder, you can run the above command with admin
privileges.
4. In Flash Builder, right-click Project > Properties and set Additional Compiler arguments to locale=ar,en_US .
Translate the supporting Adobe SDK files (optional)
Depending on which Flex components you're using, you can translate all or some of those in the
supporting Adobe SDK files. This step is optional.
Additional languages
For languages other than those listed above, translate the English resource file, i.e.
ESRIMessages.properties, to the desired language. Then compile your Flex application with the
appropriate locale as described in the following steps:
1.
2.
3.
4.
The ESRIMessages.properties file is located in the /locale/en_US directory that is part of the
API download.
FAQs
QueryTask or FeatureLayer only returns 500 or 1,000
features
By default, the server is limiting each service to returning
1,000 features at ArcGIS Server version 10.0 or later and
500 features at version 9.3. You can modify this on your
ArcGIS Server.
For more information on how to do this, please see
the setting map service propertieshelp topic.
ArcGISDynamicMapServiceLayer displays in wrong
location if map is wider than 2048 pixels
By default, the server does not allow dynamic maps
larger than 2048x2048 pixels. However, this is
configurable on your ArcGIS Server. You can set
Copyright 2016 Esri. All rights reserved.
ASP .NET Max Request length as defined in web.config. See KB article 35971 for more
info.
JavaThe default max allowed upload size is 20 MB. This can be modified by setting
the config.max-upload-size property in rest-config.properties.
2. Make sure that the REST endpoint for the service is available. For
example, http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI
_Census_USA/MapServer .
3. If your SWF is not on the same web server as your map service(s), ensure you have
acrossdomain.xml file.
4. Look at the HTTP request and response, for example, using the HttpFox (a Firefox add-on),
Fiddler, Charles and so on, to see if any of them are failing.
5. For additional information, read the Deploying your application and Using
crossdomain.xml topics, as well as the next problem in this FAQ.
The tile layer does not show on top of the dynamic layer
Currently, tiled layers display only when the scale is
exactly the same as one of the supported scale levels. If
you start your map with a dynamic layer, all scale levels
will be supported. To lock in the scale levels of a tiled
map, add the tiled layer as the basemap (first layer).
Then, on creation, reorder the layers so the dynamic
layer is on the bottom.
Why is my mobile application throwing errors when
working with pop-up windows?
There is a known-limit when working with pop-up
windows in mobile applications created with version 3.1.
If doing so, please note that you will need to either:
1. Add both mx.swc and sparkskins.swc to your project, or
2. Update PopUpRendererSkin and remove references to the RelationshipInspector component.
2. Or, if you do not wish to go with the first option, you will need to a modify
the AttributeInspectorSkin so that it no longer references CalendarField and the MemoField .
Please see the snippet below demonstrating this.
Filename
3.7
agslib-3.7(November
66c42fc1d9cc8789c8d653493bd2d9d4
2014-11-06.swc
6, 2014)
3.6
agslib-3.6(December
cdd403bdd2f844c7684350ceb5c1b526
2013-12-13.swc
13, 2013)
3.5
agslib-3.5(September
9bb53a1fce1db593881ff37c3cfae4ee
2013-09-19.swc
19, 2013)
3.4 (June agslib-3.4e502584786dea28bc9031f33521652a7
30, 2013) 2013-06-30.swc
3.3 (April agslib-3.3a651a645085c33e5eb2e20a2cd447bf8
24, 2013) 2013-04-24.swc
3.2 (March agslib-3.2e09821452f0d7998b43983f99dc2a3ed
19, 2013) 2013-03-19.swc
3.1
agslib-3.1(December
968ba76f097a996898df622fc2934a30
2012-12-12.swc
12, 2012)
3.0 (June agslib-3.0003fd279517b0265aadcee5d4ce07d54
6, 2012) 2012-06-06.swc
2.5
agslib-2.5(November
0bc96c72ae7498c6eeaeaf897587392e
2011-11-30.swc
30, 2011)
2.4 (July agslib-2.446bf6a33c58a4db6921623a549a3ee1c
25, 2011) 2011-07-25.swc
2.3.1
agslib-2.3.1(April 26,
3f3230ff42adf47a1286a3e0b536f5b7
2011-04-26.swc
2011)
2.3 (April agslib-2.3498935f8f7ecbc6e2e68498225b9f0a7
14, 2011) 2011-04-14.swc
2.2
agslib-2.2(December
09866c1fef26605ab7febddce3065134
2010-12-08.swc
8, 2010)
2.1
agslib-2.137164e154e8338ac7e39f5f2e9a3afe0
Copyright 2016 Esri. All rights reserved.
MD5 checksum
Filename
(September 2010-09-17.swc
17, 2010)
2.0 (June agslib-2.0499450929f89e737c1895a3728cbefee
25, 2010) 2010-06-25.swc
2.0 Beta
agslibUpdate 3
2.0betaUpdate3- e8395dce1d8dacc45f86dafaf2176b96
(May 18,
2010-05-18.swc
2010)
2.0 Beta
agslibUpdate 2
2.0betaUpdate2- a61547db7422754bad59aac24887d73c
(April 7,
2010-04-07.swc
2010)
2.0 Beta
agslibUpdate 1
2.0betaUpdate1- e7fb73d79208ba97a6972f41d03d2036
(February
2010-02-26.swc
26, 2010)
2.0 Beta
agslib-2.0beta(February
d95481a7f419bc573dd05fa174d4643d
2010-02-02.swc
2, 2010)
1.3
agslib-1.3(October
c294d5a1376c12a543c0c18a4fa69d7d
2009-10-31.swc
31, 2009)
1.2 (May agslib-1.21ef1e47f6767d85b3393fff4ffa6e2cd
15, 2009) 2009-05-15.swc
1.1
agslib-1.1(January
be3f53519b6943a76967a6f67c2d0f1b
2009-01-21.swc
21, 2009)
1.0
agslib-1.0(October
02c1769a61236a5d18be8fded9ad0342
2008-10-22.swc
22, 2008)
Getting help
In this topic
ArcGIS Server
Flex
MD5 checksum
Version 3.7
ArcGIS API for Flex
If you have questions about the ArcGIS API for Flex, visit the user-to-user discussionforum or
check out these additional Esri resources. The forum brings together ArcGIS API for Flex users
for collaborative online discussions and code sharing.
ArcGIS Server
For information on ArcGIS Server, visit the ArcGIS Resource Center. If you already own
ArcGIS Server, many support resources are available to help you get started and meet your
application needs.
Flex
To learn more about Apache Flex (formerly Adobe Flex), explore the following links:
What is Flex?
Apache Flex
Adobe Tour de Flex (web version)
Flex Developer Center