Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next

Building an Interactive Map

This sample displays demographic information on a map of Europe. The map includes pop-up text and drill-down links to detail data. At the bottom of the map are controls to select statistics and map type.


The Input Component

You can access the different reports from the default location:

   http://yourserver/sasweb/IntrNet8/dispatch/webmap.html

The sample page has one button, Show Map. Pushing the button submits a default form so that the default map appears on your screen. The default map, "Population Growth Rate," is a GIF image and no input fields are provided to override the defaults. The initial page also contains a link to the raw data used in this sample.

When you push the Show Map button, the returned map contains input fields that enable you to change parameters and regenerate the map. Selection lists enable you to change the data to be plotted on the map and the type of map graphic. The selection lists are implemented with hardcoded SELECT tags written by the webmap sample program. After you select data and plot type, you can replot the map by clicking the Replot button.


The Program Component

General Information

To begin generating HTML output by using ODS, submit the following statement:

   ods html ods-options path=&_tmpcat (url=&_replay) rs=none;

The ODS options control the type and destination of the HTML output that is generated by your program. At the end of your program, include the following line of code:

   ods html close;

The SAS source code for your program is placed between these two ODS statements. For more detailed information about using ODS with the Application Dispatcher, refer to The Output Delivery System (ODS).

Creating a Map

The maps are drawn using the GMAP procedure inside ODS HTML statements, and the map data sets are delivered with SAS/GRAPH software. SAS/GRAPH maps must be installed for this sample to work.

The initial map is drawn as a GIF image. A control at the bottom allows you to select SAS/GRAPH Java applets or the ActiveX Control for rendering the map. The Java applets are automatically installed on your Web server when you install the SAS/IntrNet CGI Tools package. The ActiveX Control is only supported by Internet Explorer on Windows platforms and must be installed on the client (browser) system. You can set up automatic download and installation of the ActiveX Control by installing the package (sasgraph.exe) in the directory corresponding to http://yourserver/sasweb/graph on your Web server. The SAS/GRAPH Control for ActiveX can be installed from the SAS Installation Kit or can be downloaded from the SAS Web site. The control is already installed on your Windows client system if you have installed the SAS System (Version 8).

Note that detail data for a country can be displayed by clicking on that country. Hovering the mouse over a country causes pop-up text to appear with the country name and the plotted statistic. The links and pop-up text are created by the following code:

   /* Build a map data set that includes drilldown links and alt text. */

   data eurotemp;
      set SAMPDAT.EUROSTAT;
      html = 'href="' || "&_URL" || "?_service=&_service" ||
         '&_program=' || "&_pgmlib..webmap2.sas" ||
         '&cntryid=' || left(trim(id)) ||
         '" alt="' || trim(country) || ' ' || &showvar || '"';  
         
		 /* showvar expands to a put function that formats the selected variable */
	  run;

This DATA step creates a temporary copy of the SAMPDAT.EUROSTAT data set and adds a new variable named HTML. The HTML variable contains attributes of the AREA tags used in the IMAGEMAP. The HREF= attribute defines the URL to be loaded when the specified area (corresponding to a country) is selected. The ALT= attribute defines the text to be shown in a pop-up window. The temporary data set is then plotted with PROC GMAP, and the HTML variable is specified using the HTML option:

   /* Create the map. */
   options fmtsearch=(sashelp.mapfmts);

   proc gmap map=apswork.euromap data=work.eurotemp;
      id id; format id glcnsm.;
      choro &plotvar / html = html;
      run; 

The FORMAT statement is required in order to properly format the country names for the pop-up text on Java applet and ActiveX Control maps.


Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next