CMap FAQ

From GMOD
Revision as of 14:47, 5 April 2007 by Bosborne (Talk | contribs)

Jump to: navigation, search

About this FAQ

What is this FAQ?

It is the list of Frequently Asked Questions about CMap.

How is it maintained?

It is now maintained as a Wiki on this site. You can help maintain it by adding questions and answers.

Configuration

How do I configure CMap so that when someone does mouseover a feature, it shows the name, beginning position and end position?

The "area_code" section of each feature_type (or map_type) declaration in the configuration file will allow you to modify the behavior of the features(or maps).
The "area_code" section is where you can define perl code that is executed during feature (or map) drawing. It allows you to specify a few things about the area box over the feature (or map).
There are three variables that are useful to dynamically set;
$code - Holds the javascript to be associate with the feature (or map) and is useful for creating mouse over effects and the like.
$alt - Holds the text that will be displayed in a little popup box when you hover over a feature (or map). This is specifically what you want to modify in your case.
$url - Holds the url that the feature will point to.
In the following example the $code variable is set so mousing over the feature will give the feature name in the status bar. The $alt is set to popup the feature name with the start and stop positions (as you wanted) and the $url will point to google.
 <feature_type read>
   feature_type_acc read
   feature_type Read
   area_code <<EOF
   $code=sprintf("onMouseOver=\"window.status='%s';return true\"", $feature->{'feature_name'});
   $alt =sprintf("%s: %s-%s",$feature->{'feature_name'}, $feature->{'feature_start'},$feature->{'feature_stop'});
   $url=sprintf("www.google.com/search?q=%s",$feature->{'feature_name'});
 EOF
 </feature_type>
More information can be found in the cmap/docs/ADMINISTRATION.pod documentation that comes with the CMap distribution.