WfsGetFeature.js
Summary
No overview generated for 'WfsGetFeature.js'
mapbuilder.loadScript(baseDir+"/tool/ButtonBase.js");
mapbuilder.loadScript(baseDir+"/util/openlayers/OpenLayers.js");
function WfsGetFeature(widgetNode, model) {
ButtonBase.apply(this, new Array(widgetNode, model));
this.widgetNode = widgetNode;
this.trm = widgetNode.selectSingleNode("mb:transactionResponseModel").firstChild.nodeValue
this.httpPayload = new Object({
method: "get",
postData: null
});
var typeNameNode = widgetNode.selectSingleNode('mb:typeName');
if (typeNameNode != null) {
this.typeName = typeNameNode.firstChild.nodeValue;
}
this.maxFeatures = widgetNode.selectSingleNode('mb:maxFeatures');
this.maxFeatures = this.maxFeatures ? this.maxFeatures.firstChild.nodeValue : 1;
this.webServiceUrl= widgetNode.selectSingleNode('mb:webServiceUrl').firstChild.nodeValue;
this.webServiceUrl += this.webServiceUrl.indexOf("?") > -1 ? '&' : '?';
this.cursor = "pointer";
this.createControl = function(objRef) {
var transactionResponseModel = config.objects[objRef.trm];
var Control = OpenLayers.Class( OpenLayers.Control, {
CLASS_NAME: 'mbControl.WfsGetFeature',
type: OpenLayers.Control.TYPE_TOOL, // constant from OpenLayers.Control
tolerance: new Number(objRef.widgetNode.selectSingleNode('mb:tolerance').firstChild.nodeValue),
httpPayload: objRef.httpPayload,
maxFeatures: objRef.maxFeatures,
webServiceUrl: objRef.webServiceUrl,
transactionResponseModel: transactionResponseModel,
draw: function() {
this.handler = new OpenLayers.Handler.Box( this,
{done: this.selectBox}, {keyMask: this.keyMask} );
},
selectBox: function (position) {
var bounds, minXY, maxXY;
if (position instanceof OpenLayers.Bounds) {
minXY = this.map.getLonLatFromPixel(
new OpenLayers.Pixel(position.left, position.bottom));
maxXY = this.map.getLonLatFromPixel(
new OpenLayers.Pixel(position.right, position.top));
} else {
minXY = this.map.getLonLatFromPixel(
new OpenLayers.Pixel(position.x-this.tolerance, position.y+this.tolerance));
maxXY = this.map.getLonLatFromPixel(
new OpenLayers.Pixel(position.x+this.tolerance, position.y-this.tolerance));
}
bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat, maxXY.lon, maxXY.lat);
var typeName = objRef.typeName;
if (!typeName) {
var queryList=objRef.targetModel.getQueryableLayers();
if (queryList.length==0) {
alert(mbGetMessage("noQueryableLayers"));
return;
}
else {
typeName = "";
for (var i=0; i<queryList.length; ++i) {
var layerNode=queryList[i];
var layerName=layerNode.firstChild.data;
var hidden = objRef.targetModel.getHidden(layerName);
if (hidden == 0) { //query only visible layers
if (typeName != "") {
typeName += ",";
}
typeName += layerName;
}
}
}
}
if (typeName=="") {
alert(mbGetMessage("noQueryableLayersVisible"));
return;
}
this.httpPayload.url = this.webServiceUrl+OpenLayers.Util.getParameterString({
SERVICE: "WFS",
VERSION: "1.0.0",
REQUEST: "GetFeature",
TYPENAME: typeName,
MAXFEATURES: this.maxFeatures,
BBOX: bounds.toBBOX()
});
this.transactionResponseModel.newRequest(this.transactionResponseModel, this.httpPayload);
}
});
return Control;
}
}
Documentation generated by
JSDoc on Tue Aug 21 08:12:28 2007