[Mapbender-commits] r8796 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Mar 6 07:32:21 PST 2014
Author: armin11
Date: 2014-03-06 07:32:21 -0800 (Thu, 06 Mar 2014)
New Revision: 8796
Modified:
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/mod_featureInfo.php
Log:
Possibility to allow switching between featureInfo on layer and service level based on element_var featureInfoCollectLayers. If only one layer/wms is active not interims window will be shown any longer.
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2014-03-05 08:03:13 UTC (rev 8795)
+++ trunk/mapbender/http/javascripts/map_obj.js 2014-03-06 15:32:21 UTC (rev 8796)
@@ -966,7 +966,7 @@
*
* @type string[]
*/
- this.getFeatureInfoRequestsForLayers = function(clickPoint, ignoreWms, epsg, realWorldPoint){
+ this.getFeatureInfoRequestsForLayers = function(clickPoint, ignoreWms, epsg, realWorldPoint, featureInfoCollectLayers){
var allRequests = [];
//loop through all wms to get the FeatureInfoRequests
for (var i = 0; i < this.wms.length; i++) {
@@ -981,42 +981,95 @@
}
}
if (!ignoreThisWms) {
- //get all layers for this wms which have activated featureInfo Button
- //loop over all layers of this wms
- for (var j = 0; j < this.wms[i].objLayer.length; j++) {
- if (this.wms[i].objLayer[j].gui_layer_querylayer == 1 && this.wms[i].objLayer[j].gui_layer_queryable == 1) {
- var featureInfoObj = {};
- featureInfoObj.title = this.wms[i].objLayer[j].gui_layer_title;
- //pull featureinfo request
- var featureInfoRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
- //exchange layer parameter with current layer name
- if (typeof(featureInfoRequest) !== 'undefined' && featureInfoRequest !== "" && featureInfoRequest !== false) {
- featureInfoRequest = changeURLParameterValue(featureInfoRequest,"LAYERS", this.wms[i].objLayer[j].layer_name);
- featureInfoRequest = changeURLParameterValue(featureInfoRequest,"QUERY_LAYERS", this.wms[i].objLayer[j].layer_name);
+ //switch for service based featureInfo od layer based one
+ if (featureInfoCollectLayers) {
+ //instantiate return object
+ var featureInfoObj = {};
+ featureInfoObj.title = "";
+ featureInfoObj.names = "";
+ featureInfoObj.legendurl = "";
+ var featureInfoRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+ //check if featureinfo for this service is available - push only those into return object
+ if (typeof(featureInfoRequest) !== 'undefined' && featureInfoRequest !== "" && featureInfoRequest !== false) {
+ //iterate over all layers to select those which are queryable and active which lie in the region
+ for (var j = 0; j < this.wms[i].objLayer.length; j++) {
+ if (this.wms[i].objLayer[j].gui_layer_querylayer == 1 && this.wms[i].objLayer[j].gui_layer_queryable == 1) {
+ var bbox = this.objectFindByKey(this.wms[i].objLayer[j].layer_epsg, "epsg", epsg);
+ if (bbox) {
+ //check if clicked point is in bbox of layer
+ featureInfoObj.inBbox = this.isPointInBbox(realWorldPoint, bbox);
+ } else {
+ featureInfoObj.inBbox = true;
+ }
+ if (featureInfoObj.inBbox) {
+ featureInfoObj.title += this.wms[i].objLayer[j].gui_layer_title+", ";
+ featureInfoObj.names += this.wms[i].objLayer[j].layer_name+",";
+ //get url to legend
+ if (typeof(this.wms[i].objLayer[j].layer_style[0]) !=='undefined' && typeof(this.wms[i].objLayer[j].layer_style[0].legendurl) !== 'undefined') {
+ featureInfoObj.legendurl += this.wms[i].objLayer[j].layer_style[0].legendurl+",";
+ } else {
+ featureInfoObj.legendurl += "empty"+",";
+ }
+ }
+
+ }
+ }
+ //do following things only, if some name exists!
+ if (featureInfoObj.names !=='') {
+ //exchange trailing ","
+ featureInfoObj.names = featureInfoObj.names.replace(/,+$/, "");
+ featureInfoObj.title = featureInfoObj.title.replace(/, +$/, "");
+ //check for length of title - if length is > 1 use wms title, cause window is too small!
+ /*if(featureInfoObj.title.split(",").length > 1) {
+ featureInfoObj.title = this.wms[i].wms_title;
+ }*/
+ featureInfoObj.legendurl = featureInfoObj.legendurl.replace(/,+$/, "");
+ //remove wrong layers from getFeatureInfo request
+ featureInfoRequest = changeURLParameterValue(featureInfoRequest,"LAYERS", featureInfoObj.names);
+ featureInfoRequest = changeURLParameterValue(featureInfoRequest,"QUERY_LAYERS", featureInfoObj.names);
featureInfoObj.request = featureInfoRequest;
- var bbox = this.objectFindByKey(this.wms[i].objLayer[j].layer_epsg, "epsg", epsg);
- if (bbox) {
- //check if clicked point is in bbox of layer
- featureInfoObj.inBbox = this.isPointInBbox(realWorldPoint, bbox);
+ //give back objects
+ allRequests.push(featureInfoObj);
+ }
+ }
+ } else {
+ //get all layers for this wms which have activated featureInfo Button
+ //loop over all layers of this wms
+ for (var j = 0; j < this.wms[i].objLayer.length; j++) {
+ if (this.wms[i].objLayer[j].gui_layer_querylayer == 1 && this.wms[i].objLayer[j].gui_layer_queryable == 1) {
+ var featureInfoObj = {};
+ featureInfoObj.title = this.wms[i].objLayer[j].gui_layer_title;
+ //pull featureinfo request
+ var featureInfoRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+ //exchange layer parameter with current layer name
+ if (typeof(featureInfoRequest) !== 'undefined' && featureInfoRequest !== "" && featureInfoRequest !== false) {
+ featureInfoRequest = changeURLParameterValue(featureInfoRequest,"LAYERS", this.wms[i].objLayer[j].layer_name);
+ featureInfoRequest = changeURLParameterValue(featureInfoRequest,"QUERY_LAYERS", this.wms[i].objLayer[j].layer_name);
+ featureInfoObj.request = featureInfoRequest;
+ var bbox = this.objectFindByKey(this.wms[i].objLayer[j].layer_epsg, "epsg", epsg);
+ if (bbox) {
+ //check if clicked point is in bbox of layer
+ featureInfoObj.inBbox = this.isPointInBbox(realWorldPoint, bbox);
+ } else {
+ featureInfoObj.inBbox = true;
+ }
} else {
- featureInfoObj.inBbox = true;
+ featureInfoObj.request = "empty";
+ featureInfoObj.inBbox = false;
}
- } else {
- featureInfoObj.request = "empty";
- featureInfoObj.inBbox = false;
- }
- //get url to legend
- if (typeof(this.wms[i].objLayer[j].layer_style[0]) !=='undefined' && typeof(this.wms[i].objLayer[j].layer_style[0].legendurl) !== 'undefined') {
- featureInfoObj.legendurl = this.wms[i].objLayer[j].layer_style[0].legendurl;
- } else {
- featureInfoObj.legendurl = "empty";
- }
- //return new request!
- allRequests.push(featureInfoObj);
- }
- }
- }
- }
+ //get url to legend
+ if (typeof(this.wms[i].objLayer[j].layer_style[0]) !=='undefined' && typeof(this.wms[i].objLayer[j].layer_style[0].legendurl) !== 'undefined') {
+ featureInfoObj.legendurl = this.wms[i].objLayer[j].layer_style[0].legendurl;
+ } else {
+ featureInfoObj.legendurl = "empty";
+ }
+ //return new request!
+ allRequests.push(featureInfoObj);
+ } //end queryable condition
+ } //end for layer loop
+ } //end layer or wms based featureInfo
+ } //end ignore wms condition
+ } //end for wms loop
if (allRequests.length > 0) {
return allRequests;
}
Modified: trunk/mapbender/http/javascripts/mod_featureInfo.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_featureInfo.php 2014-03-05 08:03:13 UTC (rev 8795)
+++ trunk/mapbender/http/javascripts/mod_featureInfo.php 2014-03-06 15:32:21 UTC (rev 8796)
@@ -38,6 +38,8 @@
var featureInfoDrawClick = false;
if(typeof(featureInfoCircleColor)==='undefined')
var featureInfoCircleColor = '#ff0000';
+if(typeof(featureInfoCollectLayers)==='undefined')
+ var featureInfoCollectLayers = false;
var mod_featureInfo_elName = "<?php echo $e_id;?>";
var mod_featureInfo_frameName = "";
@@ -165,30 +167,75 @@
if (featureInfoLayerPreselect) {
$("#featureInfo_preselect").remove();
//build list of possible featureInfo requests
- urls = mod_featureInfo_mapObj.getFeatureInfoRequestsForLayers(point, ignoreWms, Mapbender.modules[options.target].getSRS(), realWorldPoint);
+ urls = mod_featureInfo_mapObj.getFeatureInfoRequestsForLayers(point, ignoreWms, Mapbender.modules[options.target].getSRS(), realWorldPoint, featureInfoCollectLayers);
if (urls.length == 0 || typeof urls.length =='undefined') {
alert("<?php echo _mb("Please enable some layer to be requestable");?>!");
return false;
}
+ if (urls.length == 1) {
+ //don't show interims window!
+ //open featureInfo directly
+ if(featureInfoLayerPopup == 'true'){
+ $("<div><iframe frameborder='0' height='100%' width='100%' id='featureInfo' title='<?php echo _mb("Information");?>' src='" + urls[0].request + "'></iframe></div>").dialog({
+ bgiframe: true,
+ autoOpen: true,
+ modal: false,
+ title: '<?php echo _mb("Information");?>',
+ width:parseInt(featureInfoPopupWidth, 10),
+ height:parseInt(featureInfoPopupHeight, 10),
+ position:dialogPosition,
+ buttons: {
+ "Ok": function(){
+ $(this).dialog('close').remove();
+ }
+ }
+ }).parent().css({position:"fixed"});
+ return false;
+ } else {
+ window.open(urls[0].request, "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");
+ return false;
+ }
+ }
featureInfoList = "<table border='1'>";
if (reverseInfo == "true") {
for(var i=0;i<urls.length;i++){
- if (urls[i].inBbox) {
- if (urls[i].legendurl !== "empty" ) {
- featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
- } else {
- featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ if (featureInfoCollectLayers) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td>";
+ //get legend urls if available
+ var legend = urls[i].legendurl.split(",");
+ for(var k=0;k<legend.length;k++){
+ featureInfoList +="<img src='"+legend[k]+"' alt='<?php echo _mb("No legend available");?>!'/><br>";
}
+ featureInfoList += "</td></tr>";
+ } else {
+ if (urls[i].inBbox) {
+ if (urls[i].legendurl !== "empty" ) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ } else {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ }
+ }
+
}
}
} else {
for(var i=urls.length-1; i>=0; i--){
- if (urls[i].inBbox) {
- if (urls[i].legendurl !== "empty" ) {
- featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
- } else {
- featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ if (featureInfoCollectLayers) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td>";
+ //get legend urls if available
+ var legend = urls[i].legendurl.split(",");
+ for(var k=0;k<legend.length;k++){
+ featureInfoList +="<img src='"+legend[k]+"' alt='<?php echo _mb("No legend available");?>!'/><br>";
}
+ featureInfoList += "</td></tr>";
+ } else {
+ if (urls[i].inBbox) {
+ if (urls[i].legendurl !== "empty" ) {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ } else {
+ featureInfoList += "<tr><td valign='top'><a style='text-decoration: underline' href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='' alt='<?php echo _mb("No legend available");?>!'/></td></tr>";
+ }
+ }
}
}
}
More information about the Mapbender_commits
mailing list