Customizing the Web Mapping Application


Summary Many applications created using ArcGIS Server Manager ("Manager") are customized to meet specific needs. The Web Mapping Application ("WMA") can be customized using Visual Studio or Visual Web Developer Express Edition ("Express"). A great deal of customization can be done in Visual Studio that does not require programming. However, you can modify the application further by taking advantage of the various application programming interfaces (APIs). This topic focuses on customizing the WMA in Visual Studio without programming.

In this topic

Opening a WMA in an IDE

The first step in customizing the WMA is to open it in Visual Studio 2008. When you open the application in your integrated development environment (IDE), it is opened in Source view. The main page—Default.aspx—is comprised of Hypertext Markup Language (HTML) and JavaScript. When you change the view to Design view, a visual representation of the same information is shown. You can use these views interchangeably. As you make changes to one view, they are reflected in the other view.
The Source view format is shown in the following screen shot:
The Design view format is shown in the following screen shot:
The WMA contains a number of Web controls, which are server-side objects included as part of the Web Application Developer Framework (ADF). The WMA includes Web controls specific to mapping, such as Map, OverviewMap, and Toc (table of content) controls. There are some other controls existing in WMA that is not shown on the page. These controls are mainly used for connecting to different data sources for e.g MapResourceManager is available on the page and is not visible at runtime. It is required for connecting to different types of datasources.
The WMA also includes a number of HTML elements, such as DIV and TABLE and web controls like asp:panel that are used in formatting the page. The following screen shot is a close-up of the WMA in Design view showing a visual representation of Web controls:
Each Web control contains a set of properties. Each property has an attribute in the HTML source. In Design view, the properties are summarized in a Properties window that is located on the lower right of your IDE. The property is listed on the left, and the property value is on the right.
The following screen shot shows the Properties window:
To open an application in an IDE, perform the following steps:
  1. Open Visual Studio.
  2. Open your WMA. Click File, click Open, and click Web site.
  3. In the left panel, click Local IIS if it is not already selected.
  4. Select your application from the list and click Open.
  5. After the application opens, double-click Default.aspx in Solution Explorer located in the upper right of the IDE. Default.aspx is the main Web page that shows the layout of the application either graphically or in HTML. By default, the page opens in Source view, which shows the HTML source.
  6. In the lower left area of the IDE, click the Design tab to switch to Design view.
The Design tab is shown in the following screen shot:

Accessing Web control properties

You can access Web control properties in the following ways:
  • Right-click the Web control on the Design view page.
  • Click the drop-down arrow on the Properties window and select the Web control. See the following screen shot:

Working with the WMA file structure

When you open a WMA in an IDE, the following folders and files are listed in the Solution Explorer window:
  • App_Code—Standard ASP.NET folder for code modules used in the application. Contains Native64BitSupport.vb or Native64BitSupport.cs, which cab be used if running application in a 64-bit application pool.
  • App_Themes—Standard ASP.NET folder for application theme files, such as style sheets, skin files, and images. For more information, see the Using themes and style sheets section.
  • Help—Folder containing the Help files for the WMA. These are plain HTML files that can be customized for your application.
  • images—Folder containing images used by the WMA.
  • JavaScript—Folder containing two javascript library files used by the WMA , namely display_measure.js and WebMapApp.js.
  • ApplicationClosed.aspx—This page displays if the Close link is clicked when the Web application is using a non-pooled ArcGIS Server data source. This allows the application to release resources used on the geographic information system (GIS) server as soon as you're finished with them.
  • Default.aspx—The main Web page includes the map, associated controls, and content.
  • ErrorPage.aspx—This page is shown if the Web application encounters an unhandled error.
  • Global.asax—Contains code that runs when the application and session start and end.
  • Login.aspx—Used only when the application requires a login using a form (Forms authentication). If the application was created and security applied in Manager, this page is displayed when you open the application. If the application was created in Visual Studio or otherwise is not visible to Manager, security can be configured with other tools, such as the Web Site Administration Tool, available from the Visual Studio menu at ASP.NET Web Site Configuration.
  • Measure.ascx—A custom user control used in Default.aspx as a tool for measuring distance and area on the map.
  • PasswordRecoveryMail.txt—Contains the text to use when sending the user an e-mail to recover a lost password. Only used if the form-based login is active (see Login.aspx) and a mail server is defined in the Web.config file. For more information, see security topics in the Server Help.
  • ReadMe.txt—Contains brief instructions on setting up a WMA in Visual Studio.
  • Web.config—Standard ASP.NET configuration file that stores references to .NET assemblies used, identity when using an ArcGIS Server local data source, and other configuration settings.
The Solution Explorer window is shown in the following screen shot:
The WMA can also use files in the common ASP.NET folder, aspnet_client, which is stored in the root IIS folder. These files are typically in C:\Inetpub\wwwroot\aspnet_client\ESRI\WebADF.

Navigating Default.aspx (the mapping page)

Default.aspx is the main mapping page in the Web application. It contains Web controls to display a map along with related items such as a table of contents, an overview map, and tools to interact with the map. In addition to Web controls, the page uses a combination of panel controls, DIV elements, and tables to format the page. At the highest level, the page is divided into the following panel controls:
  • PageHeader Panel—Contains the title bar.
  • LinkBar Panel—Contains the toolbar and menu-based hyperlinks.
  • Page Content Panel—Contains Map and Control panels. The map is in a panel control called Map_Panel. The Control Panel is the area on the left that contains task and results panels, an overview map, and a table of contents. The Control Panel is contained in a table and nested in several DIV tags, the innermost being LeftPanelCellDiv. These DIV tags control the resizing and position of the Control Panel.
The following screen shot shows a sample WMA Default.aspx page in Design view:

Working with Web controls on the mapping page

The Default.aspx page contains controls for displaying and interacting with map information. The following table lists some of these controls:
ESRI ADF Web control
ASP.NET control
Custom user control
Notes
Map
 
 
None
 
 
Resource manager controls manage access to server resources. It is important to configure properties in Mapresourcemanager as establishes connections to services. Other resource mangers may be configured as required.
 
 
 
 
 
 
None
 
TitleMenu
 
Standard ASP.NET menu control.
 
SiteMapDataSource
 
Standard ASP.NET control.
Toc
 
 
All are located in the Control Panel on the left side of the Default.aspx page.
 
 
 
ZoomLevel is only visible when using ArcGIS Server fused cashed data sources.
 
 
 
 
 
 
 
 
 
 
Not active by default.
 
 
None
 
 
None
 
 
Measure
None
 
 
Can contain tasks.

Selecting an overview map

In Manager, you can include an overview map and select which service to use. Manager restricts the list of services to those already selected for display in the map. In most cases, a map shows detail appropriate for its size on the screen, including labels and symbols. Overview maps are smaller, and it is often better to show less detail. This can be accomplished by selecting a secondary service for the overview map.
To select an overview map that's not in the map, the process is as follows:
  • Add a service to the list of map resources in your IDE.
  • Hide this map from view and from the table of contents.
  • Associate the overview map with the map you added to the list of map resources.
This process is detailed in the following steps:
  1. Click the MapResourceManager control in Design view, or click the drop-down arrow on the Properties window and select MapResourceManager1.
  2. Click the ResourceItems property, and click the ellipsis button. The MapResourceItem Collection Editor dialog box opens.
  3. Click Add. A new resource is added.
  4. On the right side of the MapResourceItem Collection Editor dialog box, click the Definition property, and click the ellipsis button. The Map Resource Definition Editor dialog box opens.
  5. In the editor, select the type of service to add from the drop-down list.
  6. Click the Data Source ellipsis button and add the required information for your data source.
  7. Click the Resource ellipsis button, select a service from the drop-down list, and click OK.
  8. Click OK to close the Map Resource Definition Editor dialog box.
  9. On the right side of the MapResourceItem Collection Editor dialog box, click the Name property and type the name of your service.
  10. Click the DisplaySettings property, and click the ellipsis button. The Map Resource Display Settings Editor dialog box opens.
  11. Uncheck Visible, uncheck Display in the Table of Contents, and click OK to close the dialog box. See the following screen shot:

    Click OK to close the MapResourceItem Collection Editor dialog box.
  12. Reference the new service in the overview map by clicking the OverviewMap control in the lower left of the Design area or by clicking the drop-down arrow on the Properties window and selecting OverviewMap1.
  13. Click the OverviewMapResource property and select the service from the drop-down list.
  14. Save your changes.
  15. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.
For more information about the OverviewMap control, see OverviewMap control.
For more information on adding services, see MapResourceManager control.

Changing Navigation control properties

The Navigation control allows users to pan the map by clicking different points on the control. In Manager, you can include a Navigation control and select the font symbol or image to be used. In your IDE, you can also change the size of the north arrow, the output image format, and how quickly the map moves when it is used for navigation.
To change Navigation control properties, perform the following steps:
  1. Click the Navigation control in Design view, or click the drop-down arrow on the Properties window and select Navigation1.
  2. Change the property values as appropriate. Common Navigation control properties are as follows:
    • DisplayCharacter—The font and character index of a glyph
    • ImageFormat—The output format for the image
    • Size—The size of the image in points
    • Speed—The higher the value, the faster the map moves
  3. Save your changes.
  4. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.
For more information, see Navigation control.

Changing Toc control properties

In Web Manager, you can include a table of contents (TOC), include swatches, and allow users to turn layers on and off in the TOC. When using your IDE, you can change the font and set the TOC to be fully expanded when the application is opened.
To change Toc control properties, perform the following steps:
  1. Click the Toc control in Design view, or click the drop-down arrow on the Properties window and select Toc1.
  2. Change the property values as appropriate. Common Toc control properties are as follows:
    • ExpandDepth—A value of 2 means the TOC will expand to the second level by default. This expansion is enough to see the swatches.
    • Font—The font used for specifying layer names
    • ForeColor—The font color
    • ShowLayerCheckBoxes—Allows users to turn layers on and off
    • ShowResourceCheckBoxes—Allows users to turn services on and off
    • TocType—Allows to choose to display legend with swatches(Layer symbol) or only layer names.
  3. Save your changes.
  4. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.
For more information, see Toc control.

Changing ScaleBar control properties

While creating application using ArcGIS Server Manager, you can include a scale bar, as well as set the scale bar units, bar color, and text color. If you are using Visual Studio IDE, you can also change the scale bar font, bar height, and bar length.
To change ScaleBar control properties, perform the following steps:
  1. Click the ScaleBar control in Design view, or click the drop-down arrow on the Properties window and select ScaleBar1.
  2. Change the property values as appropriate. Common ScaleBar control properties are as follows:
    • BarColor—The scale bar color
    • BarFont—The font used for scale bar text
    • BarHeight—Height of the scale bar
    • BarUnits—Scale bar units, such as miles or kilometers
    • ForeColor—The font color
    • Width—Length of the scale bar
  3. Save your changes.
  4. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.
For more information, see ScaleBar control.

Adding a copyright statement

It is very simple and easy to add copyright to the web mapping application using Visual Studio IDE. Web mapping application template comes with MapCopyrightText control added to the map. To change copyright control properties, perform the following steps:
  1. Click the MapCopyrightText control in Design view, or click the drop-down arrow on the Properties window and select MapCopyrightText1.
  2. Change the "Text" property to display the copyright text. Other properties may be changed as required.
  3. Save your changes.
  4. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.

Adding a north arrow

While there is no option available in to add north arrow via manager. However, you can add one in via visual studio IDE. Adding a north arrow to the map is in addition to using the Navigation control, which can also be used as a north arrow.
The easiest way to add a north arrow is through the HTML source rather than in Design view.
To add a north arrow to your map, perform the following steps:
  1. Click the Source tab to access the HTML page. The Source tab is shown in the following partial screen shot:

  2. Search for "Map_Panel". You'll find the following lines of HTML code:
[HTML]
<div id="Map_Panel" style="...">
  <esri:Map ID="Map1" runat="server" ...>
  </esri:Map>
</div>
  1. Before the closing DIV tag, place the following line containing the north arrow. Modify the style attribute for your application as appropriate.
[HTML]
<div style="position:absolute; bottom:25px; left:20px;z-index:98; font-family:ESRI North;
font-size:36pt;color:Black;">
&#176
</div>
In this code, the text is placed in a DIV tag. You can format the placement location and north arrow symbol by using the style attribute. The following table lists the style properties, values and descriptions:
Style property and value
Description
position: absolute
Use absolute positioning with the text so that it does not move.
bottom: 25px; left: 20px
The placement of the text. In this case, the text is placed 25 pixels from the bottom and 20 pixels from the left.
z-index
Sets the order of the element in the stack. Use a high number so that the north arrow is always on top.
font-family: ESRI North; font-size: 36pt; color: Black
The font family, size, and color to be used. In this example, ESRI North is the font, the color is black, and the north arrow will be one half inch high based on 72 points per inch.
The north arrow is represented by a keyboard character or a character entity. The following table shows two examples:
Character
Symbol
Capital letter I or &#68
&#176 (No keyboard equivalent in English)
  1. Save your changes.
  2. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.

Using themes and style sheets

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in a Web application, across an entire Web application. Each theme is self-contained, making it easy to move among themes without affecting the code in the application.
Themes consist of a .skin and .css file plus any supporting images. These files can have any name, but the WMA has standardized the following:
  • Default.skin—Defines display properties for some of the server-side controls, such as task floating panel, and magnifier
  • MapViewerStyleSheet.css—Contains styles for many of the surrounding elements, such as the title bar area
  • Images—Used by skins and styles for background images
For a WMA, each theme is created as a separate subdirectory in the App_Themes folder as shown in the following screen shot. You can modify an existing theme or create one.
Some of the controls in a WMA do not reference a theme's style sheet. Instead, colors and fonts are set within the properties of the control. These values override attributes set in the style sheet. In the following screen shot, the Font and ForeColor (font color) properties have been set in the Properties window:
When an HTML page is sent to the client, the font information is included in the style attribute, which overrides any attributes in the style sheet. See the following code:
[HTML]
<span
  id="MapViewer_TitleTextShadowLabel"
  style="color:White;font-family:Verdana;font-size:12pt;font-weight:bold;position:
absolute; left: 5px; top: 5px;">
  Web Mapping Application
</span>
To reference a style sheet, the property values for Font and ForeColor need to be removed, and a value for CssClass needs to be added that references a class in the style sheet.

Modifying an existing theme

To modify an existing theme in an application, perform the following steps:
  1. In Solution Explorer, double-click Web.config to open the file.
  2. Scroll until you come to the theme reference. The name of the theme reflects the directory your application is currently referencing. See the following code:
[HTML]
<pages theme="Blue_Bridge"/>
Navigate to this directory in Solution Explorer.
  1. Double-click Default.skin or MapViewerStyleSheet.css to open the files. Make changes to fonts, colors, and other formatting attributes as appropriate.
  2. Save your changes.
  3. Click the Default.aspx tab to make Default.aspx the active page. See the following partial screen shot:

  4. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.

Adding a theme

To add a theme to an application, perform the following steps:
  1. Add a theme directory under App_Themes.
    1. In Solution Explorer, right-click App_Themes, and select Add ASP.NET folder.
    2. Add and rename the folder.
    3. Right-click the new folder, and select Add Existing Item.
    4. Navigate to the location of the theme folder you want to use and copy the .css and .skin files you want to use.
    5. If necessary, repeat steps a–d to add subfolders, such as one for images.
Optionally, copy an existing directory to App_Themes.
  1. Make changes to the files as needed.
  2. In Solution Explorer, double-click Web.config to open the file.
  3. Scroll until you come to the theme reference. Change the theme reference to the new folder name as shown in the following code:
[HTML]
<pages theme="mytheme"/>
  1. Save your changes.
  2. Click the Default.aspx tab to make Default.aspx the active page.
  3. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.

Referencing a theme's style sheet

To reference a theme's style sheet in a control, perform the following steps:
  1. Click the control in Design view, or click the drop-down arrow on the Properties window and select the control.
  2. Check if the control has a CssClass property. If this property is populated, the control is referencing MapViewerStyleSheet.css. To reference the style sheet if this property is not populated, set the value for CssClass to one of the classes in MapViewerStyleSheet.css. For example, set the CssClass value for MapViewer_TitleTextShadowLabel to MapViewer_TitleBarStyle.
  3. Click the Source tab.
  4. If the cursor is not already at the control you want to change, search for the control.
  5. Remove any font, color, or other formatting attributes that are included in the style sheet. For example, for MapViewer_TitleTextShadowLabel, remove all the font attributes since they are already included in the MapViewer_TitleBarStyle class.
The original code is as follows:
[HTML]
<asp:Label ID="MapViewer_TitleTextShadowLabel" runat="server" Text="Web
Mapping Application" Font-Size="12pt" Font-Names="Verdana" ForeColor="White"
Font-Bold="True" style= "position: absolute; left: 5px; top:
5px;"CssClass="MapViewer_TitleBarStyle">
</asp:Label>
The code after font attributes have been removed is as follows:
[HTML]
<asp:Label ID="MapViewer_TitleTextShadowLabel" runat="server" Text="Web
Mapping Application" style="position: absolute; left: 5px; top: 5px;"
CssClass="MapViewer_TitleBarStyle">
</asp:Label>
  1. Save your changes.

Adding or modifying template themes

To make a theme available in Manager or Web Manager, add a theme or replace an existing theme in the templates by performing the following steps:
  1. Create a theme or modify an existing theme in an application.
  2. Copy the theme directory from your application to the Manager directory typically located in the following locations:
For C#:
C:\Inetpub\wwwroot\ArcGIS\Manager\Modules\Applications\Templates\mv_cs\App_Themes

For VB:
C:\Inetpub\wwwroot\ArcGIS\Manager\Modules\Applications\Templates\mv_vb\App_Themes
  1. Close all browsers.
The next time you open Manager or Web Manager, your new or updated theme is included in the drop-down list in Page Properties.

Adding and removing tools from the toolbar

While creating an application using Manager, you can include a toolbar but it is not possible to add more tools or remove existing tools. The toolbar contains the following tools:
  • ZoomToScale—Zooms to selected/entered map scale.
  • Zoom In—Zooms in to the area of the map that you click or drag a box around
  • Zoom Out—Zooms out from the area of the map that you click or drag a box around
  • Pan—Pans the map display in the direction you drag the mouse pointer
  • Full Extent—Zooms to the full extent of the map
  • Previous Extent—Takes the map to last/previous extent
  • Forward Extent—Takes the map to next/forward extent
  • Go to Location— Allows to enter a X Y coordinates and zooms to that location
  • Identify—Lists the attributes of the feature you clicked
  • Measure—Measures distance or area
  • Magnify—Magnifies a section of the map
These tools are shown in the following screen shot:
However, it is possible to add/remove/re-arrange tools using IDE. You can use ToolbarCollectionEditorForm as show below to make changes.
To bring this form up and make changes, perform the following steps:
  1. Click the toolbar control in Design view, or click the drop-down arrow on the Properties window in Visual Studio IDE and select the toolbar control.
  2. Select ToolbarItems property and click on the ellipsis to show the ToolbarCollectionEditorForm as seen above.
  3. Make the changes and hit OK to close the form.
  4. To see your changes in a browser, click File, and click View in Browser on the drop-down menu.
For more information about the Toolbar control, see How to use the Toolbar control.

Pass initialization parameters in the URL

To provide initialization parameters in the URL of a Web Mapping Application, perform the following steps:
  1. Open Visual Studio 2008 and create a Web mapping Application using template.
  2. Set up Map and MapResourceManager by adding a valid map resource item.
  3. Double-click Default.aspx.cs in Solution Explorer.
  4. Add a member variable to store the collection of name-value pairs passed to the Web application in the URL as shown in the following code:
[C#]
public partial class _Default: System.Web.UI.Page
{

    private NameValueCollection queryvalues = null;
  1. On initialization of the page, add the Page_Init method with the following signature and code in the _Default class to capture the URL parameters using the Request.QueryString property:
[C#]
protected void Page_Init(object sender, EventArgs e)
{
    if (!IsCallback)
    {
        queryvalues = Request.QueryString;
    }
}
If the request to the page is not a callback (if it's a full page postback), the URL parameters are interrogated. Since URL parameter information is gathered during page initialization, subsequent page and control events (during the same request) can work with the query string to change properties.

In the following code, a single name-value pair is queried during the pre-render event of the page. The URL contains the name Extent and a value consisting of a set of comma delimited values to define the extent envelope or a Map control.
  1. Add the Page_PreRender method with the following signature and code in the _Default class:
[C#]
protected void Page_PreRender(object sender, EventArgs e)
{
    string[] values = queryvalues.GetValues("Extent");
    if ((values != null) && (values.Length > 0))
    {
        string[] extentparams = values[0].Split(',');
        ESRI.ArcGIS.ADF.Web.Geometry.Envelope env = new
            ESRI.ArcGIS.ADF.Web.Geometry.Envelope(Double.Parse(extentparams[0]),
            Double.Parse(extentparams[1]), Double.Parse(extentparams[2]),
            Double.Parse(extentparams[3]));
        Map1.Extent = env;
        Map1.Refresh();
    }
}
  1. Run the application. In the browser, add the custom name-value pair to the Web Mapping Application URL and reload the page. The format is Extent=minx,miny,maxx,maxy. For example, Extent=-90,30,-70,50. Include a question mark (?) after the Web Mapping Application path to indicate that a set of name-values pairs is provided. The full URL appears as follows: http://localhost/SampleWebApp/default.aspx?Extent=-90,30,-70,50. See the following screen shot: