[ka-Map-users] Overlay mouse handler implementation

Stéphane RIFF stephane.riff at cerene.fr
Wed Oct 24 09:01:36 EDT 2007


Hi every one,

I have implement a simple overlay mouse event handler.
I send you the code and hope it can help someone.
Here is how it works. You can add to your xml definition in the "point" 
element three new attributes "onclik, onmouseover, onmouseout" :

<point id="the_id"  x="x" y="y" redraw="true" onclick="pclick" 
onmouseover="pover" onmouseout="pout">

the pclick, pover and pout are your own functions names that take the 
pid for argument

example :
function pclick (pid) {
  alert(pid);
}

Here is the modification I add :

Modify the kaXmlOverlay.js file like this :
(the line starts with "++" are the ones I add)

kaXmlPoint.prototype.parse = function(point_element) {

    var i;
    var x = parseFloat(point_element.getAttribute("x"));
    var y = parseFloat(point_element.getAttribute("y"));
    var redraw_a = point_element.getAttribute("redraw");
    var redraw = false;
    if (redraw_a == "true")    redraw = true;
++    var point_id = this.pid;
++    var clickHandler = point_element.getAttribute("onclick");
++    if(clickHandler) {
++      this.div.onclick = function () { 
eval(clickHandler+"(\""+point_id+"\");"); };
++    }
++    var overHandler = point_element.getAttribute("onmouseover");
++    if(overHandler)
++      this.div.onmouseover = function () { 
eval(overHandler+"(\""+point_id+"\");"); };
++    var outHandler = point_element.getAttribute("onmouseout");
++    if(outHandler)
++      this.div.onmouseout = function () { 
eval(outHandler+"(\""+point_id+"\");"); };
           
    if (!this.shown) {
        this.placeOnMap(x,y);
        this.shown = true;
    } else {
        this.setPosition(x,y);
................
}

I hope it's clear and it can help somebody.
It's good for and seems to works well.

I can answer some questions if you needs

Thanks

-- 
Stéphane RIFF
stephane.riff at cerene.fr

CERENE SERVICES SA
3, rue Archimède
10600 La Chapelle-Saint-Luc - France
Tel : 33 (0)3 25 74 11 78
Fax : 33 (0)3 25 78 39 67
----------------------------
"Ce message peut contenir des informations confidentielles et/ou
protégées. Il est à l'usage exclusif de son destinataire. Toute
utilisation non autorisée peut être illicite. Si vous recevez ce
message par erreur, nous vous remercions d'en aviser immédiatement
l'expéditeur en utilisant la fonction réponse de votre gestionnaire
de courrier électronique."

"This email may contain confidential information and/or copyright
material. This email is intended for the use of the addressee only.
Any unauthorised use may be unlawful. If you receive this email by
mistake, please advise the sender immediately by using the reply
facility in your email software." 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stephane.riff.vcf
Type: text/x-vcard
Size: 1254 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/ka-map-users/attachments/20071024/6fbbaeed/stephane.riff.vcf


More information about the ka-Map-users mailing list