MapResourceManager control


In this topic


About the MapResourceManager control

The MapResourceManager control is usually the first control to be added to a Web application. The design time interface enables you to add, remove, and set properties for any resource that provides mapped output, for example, an ArcIMS image service or ArcGIS Server map or image service.  
Since the control can manage multiple resources at the same time, it provides properties to define how the resources interact, such as the order of layers and transparency of map image output.  
Multiple controls can use the same MapResourceManager to access the same set of resources. As a result, changes to a resource can be reflected in any control associated with the same MapResourceManager.
For more information about the MapResourceManager control, see Working with the MapResourceManager control.

Using the control

  1. To add the MapResourceManager control, open or create a Web site in Visual Studio. Open a Web form in design mode, select the Toolbox panel, and expand the ArcGIS Web Controls tab. Drag and drop a MapResourceManager control on the Web form. See the following screen shot that shows the added control in Visual Studio:


The MapResourceManager is only visible at design time.
  1. To add map resources to use in your Web application, click the control, open or navigate to the Properties window, and click the ellipsis button next to the ResourceItems property. The MapResourceItem Collection Editor dialog box appears. See the following screen shot:


  2. On the MapResourceItem Collection Editor dialog box, click the Add button to add a data source as a map resource to the MapResourceManager control. A MapResourceItem is added to the collection. This item provides properties to modify how the data source associated with this map resource displays by other controls in Web applications, such as a Map or Toc control. See the following screen shot:



    The following properties can be modified for a MapResourceItem on the Collection Editor dialog box:
    1. Name—Uniquely identifies the resource in the Web application. This name appears on the Toc control as the name of the map service at the top of the table of contents (TOC) hierarchy. Set the resource name to a descriptive value in your application (for example, the name of the map service or data frame, if applicable).
    2. DisplaySettings—When selected, this property opens a Map Resource Display Settings Editor dialog box, which is used to define the content of a map image generated by a data source. If a map image is created, transparent color and background work together to define a color that renders as transparent on a map image. See the following screen shot of the Map Resource Display Settings Editor dialog box:



      The following describes the options on the preceding Map Resource Display Settings Editor dialog box:
      • Transparency Settings—This section includes a set of options to define the visibility of a map image generated by a map resource relative to other map images in the same map resource collection. When more than one map resource is visible, map images generated by each data source blend together. How they are blended depends on the ImageBlendingMode property setting on a Map control. The map resource at the bottom of the list draws first, the one above it draws next, and so on. A single color on the map image generated by a map resource can be rendered completely transparent.

        Click the "Display this color as transparent" color picker button to choose the color, then select the "Make background transparent" check box. In many cases, the background color of a map image is set to transparent since it often references empty space. The background color of a map image is dependent on settings in the map service configuration file (for example, *.mxd). The background color for Web Application Developer Framework (ADF) graphics layer map resources is always transparent.

        You can also define variable transparency for the entire map image. A value of 0 percent means the map image will not be transparent. A value of 100 percent means the map image will be completely transparent; therefore, not visible. A value between 0 percent and 100 percent renders the contents of a map image and permits the viewing of contents on map images below it.
      • Request MIME Data—Determines how the map image is requested from the data source. If the data source supports sending a map image via Multipurpose Internet Mail Extensions (MIME) format, the image is stored in-memory by the Web ADF application. If MIME data is not supported or selected, a data source must generate an output image file and share the file location with the Web ADF application. The image format defines the type of image generated by a data source, for example, the image format generated by the ArcGIS Server container process or ArcIMS spatial server.
      • Visible—Determines if a map image is generated. If a Toc control is buddied to a Map control, the layer is selected on the Toc control if the Visible check box is select. If the Visible check box is not selected, the layer is not selected on the Toc control.
      • Display in the Table of Contents—Allows you to hide a resource in the Toc control. The resource can still be available on the Map or OverviewMap controls and used by other controls, such as SearchAttributesTask.
      • Image Format—Defines the type of image a map resource generates. The image type is important if transparency is required. Image types that support transparency are .png, .gif, and .bmp (.jpg images are not supported). To display semi-transparent symbology in Web ADF graphics layers, select PNG32 from the Image Format drop-down list for graphic map resource items. The list of image formats is static and some formats might not be available depending on the type of service you are using (for example, map document [MXD-based] ArcGIS Server, map service definition [MSD-based] ArcGIS Server, ArcIMS, and so on). If you select an image service format that the service does not support, the server reverts to its default image format. For example, if you use an MSD-based service with anti-aliasing, choose the PNG32 image format for the best visual quality. In contrast, PNG32 is not available with MXD-based services. If you choose PNG32 with an MXD-based service, the server reverts to the default of PNG24.
      • Dynamic Tiling—Applies to map resources that generate dynamic map images (not map resources associated with a cached service).

        If set to Enabled, a resource-specific tiling scheme is constructed. The tiling scheme generates a grid with a cell size based on the current Map control size. Each cell defines the bounds of a map image that is generated if the map view overlaps its extent. If the map scale remains the same, the grid remains valid. As map images are retrieved, they remain in Web browser memory and are reused. When the scale changes, the tiling scheme is reset and a new grid is defined. This option enhances user interaction with a Web ADF Map control, but requires that the map service on which the resource is based generates map images in a timely manner. Up to three dynamic map images can be requested as the result of an extent change.

        If set to Disabled, no tiling scheme is constructed for a map resource and each extent change generates a new dynamic map image. Only one map image per dynamic map resource is requested at a time. 

        If set to Default, the data source type defines whether dynamic tiling is enabled or disabled. The following table shows the default values:
        Data source type
        Dynamic tiling default values
        ArcGIS Server local
        Disabled
        ArcGIS Server Internet
        Disabled
        ArcIMS
        Enabled
        OGC and WMS
        Disabled
        Graphics
        Enabled
        Bing Maps
        Not applicable, no dynamic map services provided
         
    3. Definition—On the MapResourceItem Collection Editor dialog box, the Definition property provides a set of dialog boxes to connect to a data source provider (GIS Server) and create a map resource. Click the ellipsis button next to the Definition property to open the Map Resource Definition Editor dialog box. Click the Type drop-down list to select a data source and define the appropriate properties. The Data Source property can be a URL to an ArcGIS Server service catalog or local machine name and optional connection port. See the following screen shot:



      Some data sources support authentication. The Identity property enables you to define the appropriate runtime credentials to connect to the data source and utilize the resource. The Resource property defines the map service and if supported by the data source, the subparts (for example, map and layers) to use when working with the resource. The format of each property string is defined by the type of data source. 

      For more information, see Using the Connection library.

      The following discusses the available data source types:
      • ArcGIS Server Local—Connecting to an ArcGIS Server Local data source requires the machine name or connection host, on which the server object manager (SOM) is running. 

        On the ArcGIS Data Source Definition Editor dialog box, click the Additional GIS Servers button to set the configuration of Failover or Round-robin connections for the resource. 

        When the data source is defined, click the Resource ellipsis button on the Map Resource Definition Editor dialog box to open the ArcGIS Resource Definition Editor dialog box, which provides a list of available map and image services. In the Service list, the icon next to each service indicates the service type (map or image). 

        If a map service is selected, the Properties area on the dialog box enables the selection of the active data frame. If an image service is selected, the Properties area on the dialog box enables you to change the compression quality and the bands rendered in the output image. See the following screen shots:

             
        The Identity property on the Map Resource Definition Editor dialog box is unavailable and cannot be set. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At runtime, that identity is established by the Web application. Only one identity can be used to define access to all ArcGIS Server local data sources in a single Web application. 

        To define the identity, right-click the Web project in the Solution Explorer and select Add ArcGIS Identity. The Add ArcGIS Identity dialog box appears. On the dialog box, type the identity credentials that will be used to access ArcGIS Server local resources at runtime. This information is added to the web.config file within a standard ASP.NET identity tag. If the "Encrypt identity in web.config" check box is selected, the identity tag will be encrypted; otherwise, the user name and password is stored as clear text. See the following screen shots:


      • ArcGIS Server Internet—ArcGIS Server Web Services require entering the partial URL to the ArcGIS Manager collection of services. This URL includes the Web server host name, ArcGIS instance, and "services" folder name. This general URL provides a list of ArcGIS Server Web Services to choose from.

        If authentication is enabled for the ArcGIS Server Web service, provide a user name and password. ArcGIS Server Web services support basic, digest, and integrated authentication. Basic and digest authentication options can be used to secure ArcGIS Server Web services provided on the Internet. All options can be used to secure ArcGIS Server Web services on a local area network (LAN). Since basic and digest options can be insecure, confirm that the Web site on which ArcGIS Server Web services are available provides a secure channel for communication (it has enabled Secure Sockets Layer [SSL] encryption accessible via Hypertext Transfer Protocol Secure [HTTPS] specifications). This sufficiently encrypts the transmission of identity credentials for both authentication options.    

        Once the data source and identity (if necessary) are added, the Resource property opens the ArcGIS Resource Definition Editor dialog box, which provides a list of available map and image services. The identity determines the available services. If no identity is specified, the remote Web server is responsible for assigning an identity, often an anonymous user account. In the Service list, the icon next to each service indicates the service type (map or image).

        If a map service is selected, the Properties area on the dialog box enables the selection of the active data frame. If an image service is selected, the Properties area on the dialog box enables you to change the compression quality and the bands rendered in the output image. See the following screen shots:




        The resource definition string for a map resource item (map service) is formatted as follows:

        <layer id>@<data frame name>@<service name>

        By default, the layer ID portion of the string is not included. You can insert a layer ID in the resource definition string to define a single layer in the service you want to be accessible (for example, drawn on the map).

        To use the default data frame, specify the value (Layers) for the data frame name portion of the definition.

        The resource definition string for an image resource item (image service) is formatted as follows:

        {"type":"ImageServer","service":"<service name>","imageDescription":{"bandIds":"<band ids>",  "compressionQuality":<compression quality>}}

        The JavaScript Object Notation (JSON) formatted string consists of three name value pairs (type, service, and imageDescription). The service name, band IDs, and compression quality properties are updated on the Resource Definition Editor dialog box. On the dialog box, you can add properties to the imageDescription array of values to modify the dynamic map image generated by the image service. Only compression, noData, interpolation, and pixelType are supported. The properties reflect the GeoImageDescription created to generate a new map image. For example, define a NoData value equal to 89 to render pixels with a data value of 89 as transparent. See the following example:

        {"type":"ImageServer","service":"MyImageService","imageDescription":{"bandIds":"0",  "compressionQuality":0, "noData":89}}

        Ensure that the ArcGIS Internet data sources you use are pooled GIS services. Pooled services are shared among users of the Web application. Non-pooled service instances (processes) are dedicated to a single user and the instance is destroyed after the user finishes with it. If you use a non-pooled service in an Internet connection, a process will be created and destroyed with every map or other GIS operation. This results in an inefficient use of resources on the GIS server and is not advantageous to the application. If necessary, contact the GIS server administrator to ensure that Internet services used in the application are set to pooled status. For more information on pooling of services, see Tuning and configuring services.
       
      • ArcIMS—The following options are available for connecting to an ArcIMS data source:

        TCP—If the Web ADF application has direct network access to the ArcIMS Application Server, you can create a Transmission Control Protocol (TCP) connection. Specify the host name of the machine on which the ArcIMS Application Server is running and the connection port (default 5300). TCP connections do not use authentication; therefore, the identity credentials are not used. 

        HTTP—If the Web ADF application has access to a Web server that exposes the ArcIMS Servlet Connector, you can use an Hypertext Transfer Protocol (HTTP) connection. Specify the Web server host name and the Web ADF determines if an appropriate endpoint is available. You can alternatively specify the full path to the endpoint. By default, the Servlet Connector path is, /servlet/com.esri.esrimap.Esrimap. The ArcXMLHandler does not have a default location. If authentication has been enabled, add the appropriate information on the ArcIMS Identity Editor dialog box.

        Click the Additional IMS Servers button on the ArcIMS Data Source Definition Editor dialog box to configuring Failover or Round-robin connections for the resource. Once the connection properties have been set, use the ArcIMS Resource Definition Editor dialog box to select a map service. See the following screen shots:


       
      • OGC and WMS Service—The Open Geospatial Consortium's (OGC) Web Map Service (WMS) specification allows the publishing of geographic data on the Web in a common way. Any Web endpoint that adheres to WMS specifications can be consumed as a data source by the Web ADF. Two common WMS endpoints are provided by ArcIMS and ArcGIS Server Web services. The OGC (WMS) Data Source Definition Editor dialog box allows you to define a URL to a WMS data source. One map data source can be defined per URL. The dialog box displays the contents of the map data source upon successful connection. Select a map layer to display its metadata on the dialog box. 

        The following is the common URL for an ArcIMS WMS service: http://&lt;hostname&gt;/wmsconnector/com.esri.wms.Esrimap/&lt;servicename>.

        The following is the common URL for an ArcGIS Server WMS service: http://&lt;hostname&gt;/arcgis/services/&lt;servicename&gt;/MapServer/WMSServer.

        Identity credentials are not required to work with OGC WMS services. See the following screen shots:

            

        A subset of layers you want to include on the map using the resource definition string can be defined further. By default, the resource definition string is empty. To modify the string, view the page markup that contains the WMS map resource item. Navigate to the ResourceDefinition argument in the definition string. Add the "layerSubset" argument and define a comma-delimited list of layer names to include with the resource item. See the following example:

        ResourceDefinition=&quot;layerSubset=3,6,12&quot;

        To optimize performance, only the first 10 layers in the service are visible on the map. You can override the number of visible layers programmatically on the WMS map resource. See the following code example:
[C#]
protected void Page_Init(object sender, EventArgs e)
{
    IMapResource mapResource = MapResourceManager1.GetResource("MapResourceItem0");
    if (mapResource != null)
    {
        ESRI.ArcGIS.ADF.Web.DataSources.OGCWMSService.MapResource wmsMapResource =
            mapResource as ESRI.ArcGIS.ADF.Web.DataSources.OGCWMSService.MapResource;
        if (wmsMapResource != null)
        {
            wmsMapResource.MaxInitialSelectedLayers = 2;
            wmsMapResource.DisplayErrorAsImage = true;
        }
    }
}
      • Graphics Layers—Provides the ability to draw geometry and text on a map without necessarily being associated with a data source. By default, a graphics layer does not have content. Geometry and text, and their symbols, renderers, and attributes must be added programmatically. To display semi-transparent symbology in Web ADF graphics layers, set the Image Format to PNG32 in the Display Settings for the graphics map resource item. See the following screen shot:


      • Bing Maps—The Microsoft Live Services software development kit (SDK) hosts Bing Maps (formerly known as Virtual Earth) services providing access to a set of cached roads and aerial map imagery. Bing Maps maintains the staging and production service environments. 

        The staging environment supports development and testing use of Bing Maps services and are free of charge. 

        The production environment has optimized services to support deployed applications and requires a license fee. 

        In either case, you need a Bing Maps account ID. For more information on how to get account information or how to create an account, see Working with data sources.

        When adding a Bing Maps resource item, provide the account ID and password on the Bing Maps Identity Editor dialog box. The Bing Maps Definition Editor dialog box enables you to select the map style (Roads, Aerial, or Aerial with labels). 

        The Roads style contains detailed roads and landmarks; Aerial contains aerial imagery; Aerial with labels adds landmark labels to aerial imagery. Label culture defines the language of the labels when Aerial with labels style is used. 

        Bing Maps imagery is only provided in the Web Mercator coordinate system and cannot be re-projected on-the-fly. If you have not received a license to use the Bing Maps production environment, select the "Use staging server" check box on the Bing Maps Definition Editor dialog box. See the following screen shots:

       
    1. LayerDefinitions—Enables you to define a format for the rendering and attribute display of query results associated with each feature layer in the map resource. Creating a definition for a layer does not change the rendering of a layer on the map. It is only used to display results from the layer (for example, querying the layer). Results are displayed using Web ADF graphics. Web ADF graphics provide enhanced client-side interactivity, in this case it offers the ability to highlight the feature under the cursor, display MapTips on points, lines, and polygons, and customize attribute display in a MapTips callout box. Two Web ADF task controls, SearchAttributesTask and QueryAttributesTask, use LayerDefinitions to display results. 

      The Layer Properties dialog box shows a Layers TOC to select each feature layer in a map resource and tabs (Symbols, Fields, and Records) to define the symbology, field display, and record format for the selected layer. When finished configuring layer properties, click the Apply button on the dialog box to define these properties as part of the map resource item. See the following screen shot:

         

      The following describes each tab on the Layer Properties dialog box:

      Symbols tab—Enables you to define the default and highlight symbol for results generated using the selected layer. Click the "Draw with" or "Highlight with" button to change the symbol. When results are generated from the selected layer at runtime, features render in the Web browser using the default ("Draw with") symbol. When the cursor is hovered over a feature, the highlight symbol ("Highlight with") shows. The layer's feature type determines the options for changing the symbol. Point feature layers display a dialog box containing marker symbols. Select the symbol (the selected symbol shows in the bottom left corner on the dialog box). You can modify the marker symbols shown on the dialog box by adding and removing items in the .xml formatted usersymbols.config file in the <IISROOT>/aspnet_client/ESRI/WebADF/MarkerSymbols folder. Open the usersymbols.config file in a text editor and use the description in the header of the file to define the appropriate format for adding items. The same folder contains a symbols.config file with references to default marker symbols included with the Web ADF. Do not edit the symbols.config file because it can change in future releases. See the following screen shot:



      Line feature layers show a dialog box to change the color, width, and transparency of the symbol. Click the color box to display a color picker. Colors can be defined using red, green, blue (RGB) or hue, saturation, and luminance combinations. Transparency values range from completely transparent (0) to opaque (100). See the following screen shots:



      Polygon feature layers show a dialog box to change the boundary color, width, and transparency, and fill color and transparency. Click the color box to show a color picker. Colors can be defined using RGB or hue, saturation, and luminance combinations. Transparency values range from completely transparent (0) to opaque (100). See the following screen shots:



      Fields tab—Shows the fields in the selected layer. Select a check box next to each field name to set the field's visibility. You can also edit the text under the Alias column if you do not want to use the original field name. The "Primary display field" is used to describe the contents of a record and is set to a field that contains an intuitive, preferably unique value to identify an attribute. You can also select the "Primary display field" drop-down list. The default values on the Fields tab reflect the field aliases, visibility, and primary display field that you set in the configuration file (for example, map document, .mxd) for the map service. The values added to this dialog box overrides these settings in the current Web application. If you want the fields to appear the same way in multiple Web applications, set the field properties in the map service configuration file instead of resetting them in each Web application. See the following screen shot:



      Records tab—Shows the tabular format of results as shown in the Web browser at runtime. Record display properties for a specific layer can be used to show results in a TaskResults control or in a MapTips callout window. By default, visible fields are included in the record display as name value pairs and the title is the primary display field. See the following screen shot:



      To customize the record display, select the "Custom formatting" radio button. The Title and Contents areas on the dialog box can be edited. The Contents area contains a rich text editor to modify font style and color, or add fields, hyperlinks, tables, or images. Edits are stored as HTML style content to render in the Web browser at runtime. See the following screen shot:



      To view the HTML content used to format layer results, select the HTML radio button at the bottom of the dialog box. The raw HTML content shows in the Contents area. Valid content to render in the Web browser can be added, including HTML, CSS definitions, and JavaScript. See the following screen shot:



      If a task, such as the SearchAttributesTask, uses the default layer format for a query layer, the layer format defined with the layer's map resource item is used to render results at runtime. The following screen shot shows search results on the Cities layer using the SearchAttributesTask. The results show in a TaskResults control.

  1. To specify buddy controls, add other Web ADF controls to the Web form and buddy them with the MapResourceManager. In most cases, a Map control is buddied with a MapResourceManager by setting the map's MapResourceManager property.

Members

The following table shows a list of properties related to the MapResourceManager control. For more reference information, see the MapResourceManager control in the library reference section.
Property name
Type
Description
Initialized
bool
Indicates if the resource manager has been initialized during the current postback.
ResourceItems
GISResourceItemCollection <MapResourceItem>
Returns a collection of MapResourceItems. Each MapResourceItem references a resource instance and display settings for the item.

Events

The following table shows a list of events related to the MapResourceManager control. For more reference information, see the MapResourceManager control in the library reference section.
Event type
Description
ResourceInit
Occurs when initializing a single resource. More specifically, when the Initialize method is called with a parameter.
ResourcesDispose
Occurs when resources are disposed. More specifically, when the Dispose method is called, usually at the end of the ASP.NET page life cycle. Occurs after the rendering phase in a full page postback and after GetCallbackResult in a callback.
ResourcesInit
Occurs when all resources are initialized. More specifically, when the Initialize method is called without any parameters.


See Also:

MapResourceManager control
Using the Connection library
Working with data sources
Tuning and configuring services
Web ADF controls




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
  • ESRI.ArcGIS.ADF.Web.UI.WebControls.dll