Developing Web Applications with the Web ADF - Web controls  

MapTips control



The MapTips control enables an associated Map control to display attributes of a feature when a user hovers over a map feature. A MapTips control is associated with a single Map control via the Map property. The properties of the MapTips control determine what layer is displayed using map tips as well as how information about features is displayed to the user.

The MapTips control supports point, line, and polygon layers accessible via ArcGIS Server, ArcIMS, and Web ADF Graphics map resources.   If the data source is a remote service (e.g. ArcGIS Server, ArcIMS) the map service must return feature geometry.   Map tips are rendered in the client browser using Web ADF JavaScript Library classes and functionality.   The Web ADF JavaScript MapTips class associates graphic features (symbology and geometry) with callout windows.   Namely, when a mouse cursor hovers over a graphic feature in the map a callout window will display attribute information related to the feature.   By default, no web request to the Web application on the server is necessary to display the callout - map tips content resides solely within browser memory.       

Assembly: ESRI.ArcGIS.ADF.Web.UI.WebControls.dll
Class: ESRI.ArcGIS.ADF.Web.UI.WebControls.MapTips
Using the MapTips control
  1. Add the controls to the page

    Open or create a Web site within Visual Studio.   Open a Web form in design mode, select the Toolbox, and expand the ArcGIS Web Controls tab.  Drag and drop a MapResourceManager, a Map control, and a MapTips control onto the Web form. The placement of MapTips control is not important, as it is not visible to the user.   

    Add one or more resources to the MapResourceManager.  See the Add Resources section in the MapResourceManager control topic for information on how to do this. Also set the Map control's MapResourceManager property to Map1. See Map Control for information on setting this property. Your page should resemble the following in Visual Studio.NET:

    MapTips example in Visual Studio
  2. Set MapTips properties
    1. Select the MapTips control.  In the Properties page:

      MapTips Properties
    2. Set the Map property to the name of the Map control created and configured in the previous steps. 
    3. Note the FeatureLimit property.  This defines the maximum number of features which will be rendered as map tips at runtime.  This value may be limited by the service underlying the map resource.  For example, by default ArcGIS Server map services are limited to returning 500 features at a time.  To change this value, modify the MaxRecordCount property in the service configuration file (.cfg).   For more information, see the Service configuration files topic in the ArcGIS Server administration help system.  
    4. Set the Layer property to the map layer to use for maptips. To do this, click inside the value area of the Layer property, then click the ellipsis (...). This brings up the Map Tips Layer Editor dialog. You can also access this dialog from the MapTips control on the page, by clicking the arrow in the upper right of the control (smart tag), and choosing Set Layer. In this dialog, set the Resource Manager to the one you added earlier. Then set the Resource to a resource added in the Resource Manager. Finally, set the Layer to one of the available layers.  Click OK to close the dialog and set the Layer property.

      MapTips layer dialog
    5. Set the layer format map tips.  Choose the "Set MapTips LayerFormat" option via the smart tag (arrow on the upper right corner of the MapTips control) on the control in design-view.  

      MapTips layer dialog

      The Map Tips Expression Editor dialog will display and contain three tabs to set the symbology, fields and record format.  Each tab is covered in detail below.

      Symbols

      The Symbols tab enables you to define the default and highlight symbol for features on which MapTips have been configured.   Click on the button next to "Draw with:" or "Highlight with:" to change the symbol.   When MapTips are generated from the selected layer at runtime, features will be rendered in the browser using the default ("Draw with:") symbol.   When the mouse cursor hovers over a feature, the highlight symbol ("Highlight with:") will display.  The feature type of the layer will determine the options for changing the symbol.   The screenshot below illustrates the Symbol tab display when the MapTips layer is a polygon feature layer.    

      MapTips Expression Editor

      Point feature layers will display a dialog containing marker symbols.  Select the symbol (note the selected symbol is displayed in the bottom left corner of the dialog).   You can modify the marker symbols displayed in the dialog by adding\removing items in the xml formatted "usersymbols.config" file in the <IISROOT>/aspnet_client/ESRI/WebADF/MarkerSymbols folder.   Open the "usersymbols.config" file in your favorite 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.  The "symbols.config" file should not be edited since it may be subject to change in future releases.

      Line feature layers will display a dialog to change the color, width, and transparency of the symbol.  Click on the color box to display a color picker.  Colors can be defined using Red, Green, Blue or Hue, Saturation, Luminence combinations.  Transparency values range from completely transparent (0) to opaque (100).

      Polygon feature layers will display a dialog to change the boundary color, width, and transparency as well as the fill color and transparency.  Click on the color box to display a color picker.  Colors can be defined using Red, Green, Blue or Hue, Saturation, Luminence combinations. Transparency values range from completely transparent (0) to opaque (100). 

      Fields

      The Fields tab displays the fields in the MapTips layer and defines the field visibility and field name displayed in the map tip callout window.   The check box next to each field can be used to set the field visibility.   You can also edit the text in the Alias field if you do not want to use the original field name.  

      The primary display field is often used to describe the contents of a record.  In general, it is set to a field that contains an intuitive, preferrably unique value to identify an attribute.  You can select the primary display field using the drop down box next to "Primary display field".  

      The default values in the Fields tab reflect the field aliases, visibility and primary display field that you set in the configuration file ( e.g. map document -.mxd) for the map service.    The values entered in this dialog will only override these settings in the current Web application.   If you want the fields to appear the same way in multiple Web applications, consider setting the field properties in the map service configuration file instead of resetting them in each Web application.


      MapTips Expression Editor


      Records

      The Records tab displays the tabular format of MapTips as displayed in the callout within the browser at runtime.   By default, visible fields are included in the record display as name value pairs and the title is the primary display field.   To customize the look and feel of record display, select the Custom Formatting radio button.  The Title and Contents sections of the dialog are now editable.  The Contents section provides 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 be rendered in the browser at runtime.  Note, the fields whose values will be displayed in the title and content of the MapTip callout are included in brackets "{<field name>}".   

      MapTips Expression Editor


      The Rich Text toolbar contains a set of tools to enhance how records are displayed in the MapTips callout window.  The following diagram indicates the title of each tool.

      MapTips Expression Editor

        
      The font style settings enable you to modify text within the contents display.  The Add Field tool provides a list of fields in the MapTips layer which can be added to the contents display.   The Add Hyperlink tool will add a hyperlink to selected text or a field values.  Add Table will add an HTML table to the contents display which can be used to better organize content.  The Add Image tool will add an image tag and enable you to define the url to an image.  The url may be constructed from a field value. 

      To view the HTML content that will be used to format layer results, select the HTML radio button at the bottom of the dialog.  The raw HTML content will be displayed in the Content window.  Any valid content to be rendered in a browser can be added - this includes HTML, CSS definitions, and JavaScript.  See the Setting Title and Contents using HTML discussion topic below for more information.

      After setting the MapTips layer format via the expression, click OK to close the dialog and save the settings.  The layer format will be saved as a JSON formatted string to the Layer property on the MapTips control. 

    6. Additional properties can be configured to change how the maptips behave at runtime.  See the Properties section below for information on property settings.  To further enhance the layout and content of the map tip, see the discussion section below.
  3. Runtime use
      
    At runtime, map tips will be rendered in the map as client graphic features.  On hover of a graphic feature the map tip title will be displayed.  On click the map tip content will expand to view.  Here's an example view:

    MapTips Expression Editor
       
Members

Properties

The following table provides a list of properties of interest.  For complete reference information, see the MapTips control in the library reference section.
Property Name  Type Description
FeatureLimit int Maximum number of maptips displayed on the Map at a given time.  This value may be limited by the service underlying the map resource.  For example, by default ArcGIS Server map services are limited to returning 500 features at a time.  To change this value, modify the MaxRecordCount property in the service configuration file (.cfg).   For more information, see the Service configuration files topic in the ArcGIS Server administration help system. 
Layer string Layer, along with MapResourceManager and Resource for which maptips are displayed.
Map string ID of the Map control in which the map tips are displayed.
ShowOnlyWhenLayerIsVisible bool Whether to display maptips only when the layer is visible, and not when the layer is turned off or invisible due to scale factor settings.
WhereClause string Displays maptips only for features matching the expression.


Discussion