kaQuery.js
Summary
No overview generated for 'kaQuery.js'
Method Summary
|
static Object
|
myQuery( eventID, queryType, coords ) * { * alert( "QUERY: " + queryType + " " + coords ); * } * * Querying actually does nothing except generate a KAMAP_QUERY event with * the query type and coordinates passed as parameters to the event handler * * Signature of the query event handler is: * * function myQueryHandler( eventID, queryType, queryCoords ) * * eventID: int, KAMAP_QUERY * * queryType: int, one of KAMAP_POINT_QUERY or KAMAP_RECT_QUERY * * queryCoords: array, array of two or four floating point coordinates * depending on the query type * * You can affect the style of the zoom box by changing oQuery.domObj.style as * you would with any other HTML element (it's a div). * *****************************************************************************/ var KAMAP_QUERY = gnLastEventId ++; var KAMAP_POINT_QUERY = 0; var KAMAP_RECT_QUERY = 1; function kaQuery( oKaMap, type )
|
var KAMAP_QUERY = gnLastEventId ++;
var KAMAP_POINT_QUERY = 0;
var KAMAP_RECT_QUERY = 1;
function kaQuery( oKaMap, type ) {
kaTool.apply( this, [oKaMap] );
this.name = 'kaQuery';
this.cursor = 'help';
this.domObj = document.createElement( 'div' );
this.domObj.style.position = 'absolute';
this.domObj.style.top = '0px';
this.domObj.style.left = '0px';
this.domObj.style.width = '1px';
this.domObj.style.height = '1px';
this.domObj.style.zIndex = 100;
this.domObj.style.visibility = 'hidden';
this.domObj.style.border = '1px solid red';
this.domObj.style.backgroundColor = 'white';
this.domObj.style.opacity = 0.50;
this.domObj.style.mozOpacity = 0.50;
this.domObj.style.filter = 'Alpha(opacity=50)';
this.kaMap.theInsideLayer.appendChild( this.domObj );
this.startx = null;
this.starty = null;
this.endx = null;
this.endy = null;
this.bMouseDown = false;
this.type = type;
for (var p in kaTool.prototype) {
if (!kaQuery.prototype[p])
kaQuery.prototype[p]= kaTool.prototype[p];
}
};
kaQuery.prototype.drawZoomBox = function() {
if (this.startx == null || this.starty == null ||
this.endx == null || this.endy == null ) {
this.domObj.style.visibility = 'hidden';
this.domObj.style.top = '0px';
this.domObj.style.left = '0px';
this.domObj.style.width = '1px';
this.domObj.style.height = '1px';
return;
}
this.domObj.style.visibility = 'visible';
if (this.endx < this.startx) {
this.domObj.style.left = (this.endx - this.kaMap.xOrigin) + 'px';
this.domObj.style.width = (this.startx - this.endx) + "px";
} else {
this.domObj.style.left = (this.startx - this.kaMap.xOrigin) + 'px';
this.domObj.style.width = (this.endx - this.startx) + "px";
}
if (this.endy < this.starty) {
this.domObj.style.top = (this.endy - this.kaMap.yOrigin) + 'px';
this.domObj.style.height = (this.starty - this.endy) + "px";
} else {
this.domObj.style.top = (this.starty - this.kaMap.yOrigin) + 'px';
this.domObj.style.height = (this.endy - this.starty) + "px";
}
};
kaQuery.prototype.onmouseout = function(e) {
e = (e)?e:((event)?event:null);
if (!e.target) e.target = e.srcElement;
if (e.target.id == this.kaMap.domObj.id) {
this.bMouseDown = false;
this.startx = this.endx = this.starty = this.endy = null;
this.drawZoomBox();
return kaTool.prototype.onmouseout.apply(this, [e]);
}
};
kaQuery.prototype.onmousemove = function(e) {
e = (e)?e:((event)?event:null);
if (!this.bMouseDown) {
return false;
}
if (this.type == KAMAP_RECT_QUERY) {
var aPixPos = this.adjustPixPosition( e.clientX, e.clientY );
this.endx=-aPixPos[0];
this.endy=-aPixPos[1];
this.drawZoomBox();
}
return false;
}
;
kaQuery.prototype.onmousedown = function(e) {
e = (e)?e:((event)?event:null);
if (e.button==2) {
return this.cancelEvent(e);
} else {
if (this.kaMap.isIE4) document.onkeydown = kaTool_redirect_onkeypress;
document.onkeypress = kaTool_redirect_onkeypress;
this.bMouseDown=true;
var aPixPos = this.adjustPixPosition( e.clientX, e.clientY );
this.startx=this.endx=-aPixPos[0];
this.starty=this.endy=-aPixPos[1];
this.drawZoomBox();
e.cancelBubble = true;
e.returnValue = false;
if (e.stopPropogation) e.stopPropogation();
if (e.preventDefault) e.preventDefault();
return false;
}
};
kaQuery.prototype.onmouseup = function(e) {
e = (e)?e:((event)?event:null);
var type = KAMAP_POINT_QUERY;
var start = this.kaMap.pixToGeo( -this.startx, -this.starty );
var coords = start;
if (this.startx!=this.endx&&this.starty!=this.endy) {
type = KAMAP_RECT_QUERY;
coords = start.concat(this.kaMap.pixToGeo( -this.endx, -this.endy ));
if(coords[2] < coords[0]) {
var minx = coords[2];
var maxx = coords[0];
coords[0] = minx;
coords[2] = maxx;
}
if(coords[1] < coords[3]){
var miny = coords[1];
var maxy = coords[3];
coords[3] = miny;
coords[1] = maxy;
}
}
this.kaMap.triggerEvent(KAMAP_QUERY, type, coords);
this.startx = this.endx = this.starty = this.endy = null;
this.drawZoomBox();
return false;
};
Documentation generated by
JSDoc on Wed Mar 15 10:50:59 2006