[Chameleon] maptips without popup

Jason Fournier jfournier at dmsolutions.ca
Fri Jan 6 21:53:34 EST 2006

Hi Ken-ichi,

Actually, this was addressed not too long ago on the list:


I have implemented a preconfigured maptips instance before.  The following code will do what you want:


<div id="resultTips" style="position:absolute;visibility:hidden;"></div>
<cwc2 type="MapTips" visible="false" defaulttext="&nbsp;" tolerance="8" maptipsdiv="ttt" label="Map Tips" styleresource="TextButtons" popupstyleresource="TextButtons" popupwidth="500" popupheight="450" image="images/icon_maptips.png" layer="Fire Stations" onmouseover="maptipsOver" onmouseout="maptipsOut"  attributes="DEPT,NAME,ADDR">
             <image state="normal"/>
             <image state="selected"/>
             <image state="hover"/>

<script type="text/javascript">

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// Variables to hold mouse x-y
var mouseX = 0;
var mouseY = 0;

function getMouseXY(e) {

 if (IE) { // grab the x-y pos.s if browser is IE
   mouseX = event.clientX + document.body.scrollLeft;
   mouseY = event.clientY + document.body.scrollTop;
 } else {  // grab the x-y pos.s if browser is NS
   mouseX = e.pageX;
   mouseY = e.pageY;
 // catch possible negative values in NS4
 if (mouseX < 0){mouseX = 0;}
 if (mouseY < 0){mouseY = 0;}

 // return
 return true;

function maptipsOver(e, att_values, att_names)
   // get the mouse xy

   // position the map tip
   CWCDHTML_SetLayerZOrder( 'resultTips', 999 );
   CWCDHTML_SetLayerPos('resultTips', (mouseX + 10), (mouseY + 10));

   // set the contents
   CWCDHTML_ShowContents( 'resultTips',
                          '<div style="border: 2px solid #ccc; background-color: #eee; padding: 5px;">'+
                          '<p>'+att_values[2]+' ['+att_values[0]+']</p>'+

   // show the tip
   CWCDHTML_ShowLayer( 'resultTips' );

function maptipsOut( e, att_values, att_names)

   // hide the tip
   CWCDHTML_HideLayer( 'resultTips' );



In the widget declaration you have the following:

_maptipsdiv_: I *believe* this is for a static div container for the results; I didn't need it for dynamic because I wanted the tip to appear at the location of the mouse.
_layer_: name of the layer to use.
_attributes_: attributes to pass to the callback onmouseover for that location.

This could be done much cleaner and more efficiently ... at least it can give you a start.


Best Regards,

Ken-ichi wrote:
> Hey all.  Is there a way to use the MapTips widget on only one layer, 
> without having a button or a popup?  I would just like one layer to be 
> annotated with maptips by default, so when the mouse hovers over a 
> county, say, the county's name appears in a div.  Can this be done?
> Thanks.
> -Ken-ichi
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

Jason Fournier

DM Solutions Group Inc.
jfournier at dmsolutions.ca
613.565.5056 x18

More information about the Chameleon mailing list