proprieté d'une classe 'undefined'
hello,
je développe un petit outil pour ka-map (exemple ici : http://maps.dmsolutions.ca/demo/us_streets/iframe.html)afin de faire des requetes lorsque ma souris s'arrete au dessus d'un point un certain temps. Le problème se situe dans la fonction mouseStop : le "alert(this.coordX)" me renvoie "undefined", tout comme "alert(x)". Pourtant en testant dans la fonction mouseMove avec un "alert(this.coordX)" (en bougeant un minimum la souris au dessus du div...), j'ai quelque chose de valable.
Quelqu'un saurait ou se trouve le problème ? merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// A tool allowing to get info of point interests under
// mouse cursor on mouse stop
var queryInfos = function(oKaMap, szID, delay) {
this.kaMap = oKaMap;
this.name = 'queryInfos';
this.chrono = null;
this.coordX = "";
this.coordY = "";
this.delay = delay;
this.mouseStopped = false;
this.bInfoTool = true;
this.mouseStopped = false;
// héritage des mouse functions de kaTool
for (var p in kaTool.prototype){
if (!queryInfos.prototype[p]){
queryInfos.prototype[p]= kaTool.prototype[p];
}
}
}
queryInfos.prototype.onmousemove = function(e){
if (navigator.appName!="Microsoft Internet Explorer"){
this.coordX = e.pageX;
this.coordY = e.pageY;
}
else if(document.documentElement.clientWidth > 0){
this.coordX = event.x+document.documentElement.scrollLeft;
this.coordY = event.y+document.documentElement.scrollTop;
}
else{
this.coordX = event.offsetX;
this.coordY = event.offsetY;
}
if(this.chrono != null){
clearTimeout(this.chrono); //reset du chrono
}
var adjCoords = this.adjustPixPosition(this.coordX, this.coordY);
var p = this.kaMap.pixToGeo(adjCoords[0], adjCoords[1]);
this.coordX = p[0];
this.coordY = p[1];
//ici "alert(this.coordX)" me renvoie une coordonnée valable
if(this.mouseStopped == false){
this.chrono = setTimeout("queryInfos.prototype.mouseStop(this.coordX, this.coordY)", this.delay);
}
}
queryInfos.prototype.mouseStop = function(x,y){
alert(x); // renvoie undefined
alert(this.coordX); // renvoie undefined
clearTimeout(this.chrono);
this.mouseStopped = true;
//this.callFct(x,y);
this.mouseStopped = false;
} |