[ka-Map-users] Overlay mouse handler implementation

The Bun rosario.carbone at ipl.com
Thu Oct 25 09:25:24 EDT 2007




Stéphane RIFF wrote:
> 
> 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." 
> 
> 
> begin:vcard
> fn;quoted-printable:St=C3=A9phane RIFF
> n;quoted-printable:RIFF;St=C3=A9phane
> org;quoted-printable:CERENE Services;Informatique et D=C3=A9veloppement
> adr;quoted-printable:;;3, rue Archim=C3=A8de;La Chappelle
> Saint-Luc;Aube;10600;FRANCE
> email;internet:stephane.riff at cerene.fr
> title:Informatique
> tel;work:+33 3 25 74 11 78
> tel;fax:+33 3 25 78 39 67
> tel;cell:+33 6 32 84 37 79
> note;quoted-printable:"Ce message peut contenir des informations
> confidentielles et/ou=0D=0A=
> 	prot=C3=A9g=C3=A9es. Il est =C3=A0 l'usage exclusif de son destinataire.=
> 	 Toute=0D=0A=
> 	utilisation non autoris=C3=A9e peut =C3=AAtre illicite. Si vous recevez=
> 	 ce=0D=0A=
> 	message par erreur, nous vous remercions d'en aviser
> imm=C3=A9diatement=0D=0A=
> 	l'exp=C3=A9diteur en utilisant la fonction r=C3=A9ponse de votre
> gestionn=
> 	aire=0D=0A=
> 	de courrier =C3=A9lectronique."=0D=0A=
> 	=0D=0A=
> 	"This email may contain confidential information and/or copyright=0D=0A=
> 	material. This email is intended for the use of the addressee
> only.=0D=0A=
> 	Any unauthorised use may be unlawful. If you receive this email by=0D=0A=
> 	mistake, please advise the sender immediately by using the reply=0D=0A=
> 	facility in your email software."
> url:http://www.cerene.fr
> version:2.1
> end:vcard
> 
> 
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
> 
> 

Sorry I have just realized you wrote the handler and I made it worse because
my example was wrong, it has to be like:

function pover( point_id ) { 
                        alert( point_id ); 
                     };     

Because the handler expects the id not the full point object, I should learn
to read twice before to post comments.

Rosario
-- 
View this message in context: http://www.nabble.com/Overlay-mouse-handler-implementation-tf4684319.html#a13406788
Sent from the ka-map-users mailing list archive at Nabble.com.




More information about the ka-Map-users mailing list