MapLog.namespace("MapLog.Control");
MapLog.Control.TracQuery = OpenLayers.Class(OpenLayers.Control,{
/**
* default handler configuration options
*/
defaultHandlerOptions: {
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
/**
* click handler
*/
handler: undefined,
/**
* size
*/
size: new OpenLayers.Size(300,200),
/**
* query layer
*/
qlayer: undefined,
/**
* ext container instead of popup
*/
extContainer: undefined,
/**
* print results to popup
*/
usePopup: true,
/**
* popup class
*/
popupClass: OpenLayers.Popup.FramedCloud,
/**
* Contructor: OpenLayers.Control.UnitSwitcher
* Switcher for MapLog units
*
* Parameters:
* layer - {OpenLayers.Layer.UnitLayer}
* qlayer - {String} query layer name
* options - {Object} configuration options
*/
initialize: function(layer,qlayer,options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
this.handler = new OpenLayers.Handler.Click(
this, { 'click': this.trigger
}, this.handlerOptions);
this.qlayer = qlayer;
this.layer = layer;
},
/**
* Triger click action
*/
trigger: function(e) {
var feature = this.unitsLayer.getFeatureFromEvent(e);
var lonlat = this.map.getLonLatFromPixel(e.xy);
var bounds = this.map.getExtent();
var size = this.map.getSize();
if (this.popup) {
this.map.removePopup(this.popup);
this.popup.destroy();
}
if (!feature) {
if (!this.layer.params.IDS) {
return;
}
// var url = this.layer.getFullRequestString({mode:"query",
// qlayer:(this.qlayer ? this.qlayer : this.layer.params.layers),
// "map_projection": this.map.projection.getCode(),
// "imgxy": e.xy.x+" "+e.xy.y,
// "mapsize": size.w+" "+size.h,
// "imgext":bounds.left+" "+bounds.bottom+" "+bounds.right+" "+bounds.top
// });
var params = {
IDS: this.layer.params.IDS,
fromTime: this.layer.params.fromTime,
toTime: this.layer.params.toTime,
EPSG: this.map.projection.getCode().split(":")[1],
xclick: lonlat.lon,
yclick: lonlat.lat,
imgext: bounds.left+" "+bounds.bottom+" "+bounds.right+" "+bounds.top
};
var url = OpenLayers.Util.urlAppend(MapLog.Control.TracQuery.PositionDetailURL,
OpenLayers.Util.getParameterString(params));
this.popup = new this.popupClass(undefined, lonlat,
this.size,
"
",
null,
true);
this.map.addPopup(this.popup);
OpenLayers.Request.GET({
url: url,
scope: this,
success: this.displayResult
});
}
else {
var temp_cze = '