[Chameleon] maptips question

Jason Fournier jfournier at dmsolutions.ca
Thu Dec 29 18:53:48 EST 2005


Hi Bart,

I have implemented a preconfigured maptips instance before.  The following (very ugly) 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"/>
          </cwc2>

<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
    getMouseXY(e);

    // 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><strong>'+att_values[1]+'</strong></p>'+
                           '<p>'+att_values[2]+' ['+att_values[0]+']</p>'+
                           '</div>');

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

function maptipsOut( e, att_values, att_names)
{

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

</script>

<!----------------------------------------------->

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,
Jason



Bart van den Eijnden wrote:
> Hi list,
> 
> the maptips widget is implemented as a popup widget.
> 
> Is there a way to have a certain imagemap by default in your Chameleon 
> application without presenting the user with a dialog?
> 
> Best regards,
> Bart
> 

-- 
________________________
Jason Fournier

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


More information about the Chameleon mailing list