Layer tag
http://resources.arcgis.com/en/help/flex-viewer/concepts/
Data content in the ArcGIS Viewer for Flex application ("the Viewer") is defined by layers. A layer references a web service being accessed by the Viewer. The Viewer supports many different layer data sources, such as cached or dynamic map services, and Bing Maps. It can display layers as either basemaps or operational layers. See the following illustration of map layers:
The <layer> tag is a map service displayed as a layer in the Viewer. It must be enclosed within a <basemaps> or <operationallayers> tag, which is enclosed within a <map> tag. See the Main configuration file topic for more details on using layers in the Viewer.
The <layer> tag has the following attributes:
- label—Name of the layer.
- type—Type of layer. Possible layer types are as follows:
- tiled—Cached ArcGIS map service (9.3 or later).
- dynamic—Non-cached ArcGIS map service (9.3 or later).
- feature—Single layer in an ArcGIS map service or feature service (9.3 or later).
- bing—Microsoft Bing layer (requires a Bing Maps key).
- image—ArcGIS Server Image Service (9.3 or later).
- arcims—ArcIMS Service (9.3 or later if using a Web Mercator projection).
- osm—Basemap from OpenStreetMap.
- wms—WMS service. [Added in version 2.2]
- kml—KML feed.[Added in version 2.4]
- alpha—Adjusts the transparency/opacity of the layer. Values range from 0.0 (transparent) to 1.0 (opaque). Default is 1.0.
- autorefresh—Sets how often (in seconds) to refresh the layer (useful when the data on the server changes often). Only applies to layers of type dynamic or arcims.
- displaylevels —Specifies the scale level at which the layer should be displayed. Only applies to tiled and bing layers.
- imageformat—Specifies a specific image output format, for example, .png. Supported image formats for various layer types are as follows:
Layer type
Supported image format
Dynamic
png8, png24, png32, jpg, and gif
Image
jpgpng, png8, png24, png32, jpg, and gif
ArcIMS
gif, jpg, png8, and png24
WMS
png, jpg, and gif
Note:Support for the jpgpng format was added at ArcGIS Server 10.0. This format returns a JPG if there are no transparent pixels in the requested extent, otherwise it returns a PNG.
- token—Token value used for accessing secured ArcGIS Server services. Only applies to layers coming from ArcGIS Server, that is, dynamic, feature, image, or tiled.
- url—URL location of the map service. Does not apply to layers of type arcims, bing or osm. Required for other layers.
- useproxy—Used for map services that have a proxy server. Boolean value, default is false.
- usemaptime—Used for time-aware map services (i.e., dynamic, feature or image). Boolean value, default is true. Useful in combination with the Time Slider widget to make time-aware layers ignore their time awareness. Introduced in version 2.2.
- visible—Determines whether the layer is visible when the application first opens. Boolean value, default is false.
- visiblelayers—Determines the sublayers to show when the application first opens. The default is as specified on the server. Only applies to dynamic, arcims, and wms. It's required for WMS, or no sublayers will be shown.
Child tag specific to layers of types dynamic and tiles
<sublayer> supports the following attributes:
- id—The ID, usually a number, of the sublayer within the map service.
- popupconfig—URL to the .xml configuration file of the pop-up window. See Pop-up configuration files for more information. [Added in version 2.3]
- definitionexpression—Limits the data to a subset of the available features in the map service layer. It's similar to the definition query for a layer in ArcMap.
Child tag specific to layers of type feature
<clustering> supports one child tag and two attributes. [Added in version 2.4]
- <clustering> tag attributes
- mingraphiccount—Minimum number of graphics to display in a cluster, before rendering the cluster using the clusterer symbol.
- sizeinpixels—Cluster size in pixels. Default value is 70 pixels.
- Child tag for the <clustering> tag
- <clustersymbol>
- The <clustersymbol> tags have the following attributes:
- type—In version 2.4, the only supported value is "simple".
- alpha—The alpha transparency of the cluster symbol. Default is 0.75.
- color—Color of the cluster symbol. Default is 0x76D100 (turtle green).
- size—Size of the cluster symbol. Default is 70.
- textcolor—Color of the text within the cluster symbol. Default is black.
- alphas—The different alphas to use for classes within the matching weights. Only applicable when weights have been set. The transparency will default to alpha for class breaks not specified in this attribute.
- colors—The different colors to use for classes within the matching weights. Only applicable when weights have been set. The color will default to color for class breaks not specified in this attribute.
- sizes—The different sizes to use for classes within the matching weights. Only applicable when weights have been set. The symbol size will default to size for class breaks not specified in this attribute.
- weights—The different class breaks, for example weights="50,100", will create two classes: one with feature counts between 1 and 50, and another for 51–100 features. Use together with the alphas, colors, and sizes attributes to create symbology based on the feature count. Clusters that don't fall into these class breaks will use the symbology specified by the alpha, color, and size attributes.
The following clustering example creates three categories of different sized cluster symbols based on the feature count for each cluster. The class breaks are defined using the weights attribute. To set up three classes—one for 1–10 features, another for 11–100 features, and a third for 101–9,999 features—use weights="10,100,9999". If there are any clusters with more than 9,999 features, they would use the defaults (as specified above) or any alpha, color, or size attribute defined.
- Clusters with 1–10 features: size will be 30, color 0xFFFF00 (yellow).
- Clusters with 11–100 features: size will be 60, color 0xFFA500 (orange).
- Clusters with 101–9,999 features: size will be 90, color 0xFF0000 (red).
<layer label="San Francisco 311"
type="feature"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0"
popupconfig="popups/PopUp_311.xml"
visible="true">
<clustering mingraphiccount="2" sizeinpixels="80">
<clustersymbol type="simple"
colors="0xFFFF00,0xFF5000,0xFF0000"
sizes="30,60,90"
textsize="14"
weights="10,100,9999" />
</clustering>
</layer>
Attributes specific to layers of type feature
- popupconfig—URL to the xml configuration file of the pop-up window. Works with layers of type dynamic, tiled, and feature. [Added in version 2.3]
- mode—The caching mode to use. Valid values are onDemand and snapshot.
- definitionexpression—Limits the data to a subset of the available features in the map service layer. It is similar to the definition query for a layer in ArcMap.
- useamf—The message format between client and server (to use AMF instead of JSON). It's not required but allows you to overwrite the default. On the server side, ArcGIS 10 supports AMF, but ArcGIS 9.3 does not.
- info—URL to the info widget. Tip:
As of version 2.3 we recommend using popupconfig instead of info & infoconfig.
- infoconfig—URL to the xml configuration file for the info widget.Tip:
As of version 2.3 we recommend using popupconfig instead of info & infoconfig.
Attributes specific to layers of type image
- bandids—Comma-separated list of the band IDs to use for a specific image service (optional). [Added in version 2.3]
Attributes specific to Bing Maps
- style—Valid values are road (default), aerial, or aerialWithLabels.
- culture—Language to use for the labels on Bing Maps' road or aerialWithLabels styles (for example, en-US or sv-SE). See the Microsoft Bing Maps REST documentation for the list of supported cultures.
Bing Maps require a Bing key for maps and geocoding. See <bing key="your-bing-key"/> in the main configuration file for information on how to add a Bing key, and the Flex API documentation for information on how to get a Bing key.
Attributes specific to ArcIMS
- servicehost —URL of the ArcIMS server.
- servicename—Name of the ArcIMS service.
Attributes specific to WMS
The WMS service does not specify which layers should be visible by default, so make sure to use the visiblelayers attribute (listed above) or no sublayers will be shown.
- skipgetcapabilities—Gives the option to skip the initial request to get capabilities. Set skipgetcapabilities to true if the site hosting the WMS service does not provide a cross domain policy file and you do not have a proxy page (optional).
- version—Version to use when requesting WMS maps. Allowed values are 1.1.0, 1.1.1, or 1.3.0. (optional).
- wkid—Overwrites the WKID sent to the WMS server. Only needed if the WMS server doesn't recognize your map's wkid. [Added in version 2.3.1]
Attribute specific to KML
The KML needs to be a publicly accessible KML file (*.kml, *.kmz).
- serviceurl—Optional, URL to your own utility service for converting KML files to features. [Added in version 2.5]
Code sample
The config.xml file code sample is as follows:
<layer label="Streets"
type="tiled"
visible="true"
url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
...
Troubleshooting
- If your Flex viewer is on a domain other than the ArcGIS or ArcIMS layer you are adding, the machine with the ArcGIS or ArcIMS layer must have a crossdomain.xml file.
- All 9.x versions of ArcIMS are supported in general, but not all of them recognize newer spatial references. If you're using a newer projection in your basemap, your ArcIMS server may not be able to work with it.
- The URL for dynamic and tiled services normally ends in /MapServer and contains /rest/.
- The URL for a feature layer should end with a number, for example /MapServer/0, when used with a map service or feature service. When used with an Image Service, the URL for a feature layer should end in /MapServer.