[Mapbender-commits] r5517 - in trunk/mapbender/http: javascripts
plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Feb 19 05:22:28 EST 2010
Author: christoph
Date: 2010-02-19 05:22:27 -0500 (Fri, 19 Feb 2010)
New Revision: 5517
Modified:
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/wms.js
trunk/mapbender/http/plugins/mb_print.js
Log:
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2010-02-19 10:13:57 UTC (rev 5516)
+++ trunk/mapbender/http/javascripts/map_obj.js 2010-02-19 10:22:27 UTC (rev 5517)
@@ -727,7 +727,8 @@
*/
this.getMapUrl = function(ii, extent){
var currentWms = this.wms[ii];
- var validLayers = currentWms.getLayers(this);
+ var validLayers = (arguments.length === 3 && typeof arguments[2] === "number") ?
+ currentWms.getLayers(this, arguments[2]) : currentWms.getLayers(this);
if (validLayers.length === 0) {
return false;
}
Modified: trunk/mapbender/http/javascripts/wms.js
===================================================================
--- trunk/mapbender/http/javascripts/wms.js 2010-02-19 10:13:57 UTC (rev 5516)
+++ trunk/mapbender/http/javascripts/wms.js 2010-02-19 10:22:27 UTC (rev 5517)
@@ -291,7 +291,10 @@
* @type string[]
*/
wms_const.prototype.getLayers = function(mapObj){
-
+ var scale = null;
+ if (arguments.length === 2) {
+ scale = arguments[1];
+ }
try {
//visibility of the wms
var wmsIsVisible = (this.gui_wms_visible > 0);
@@ -303,7 +306,7 @@
var isVisible = (this.objLayer[i].gui_layer_visible === 1);
var hasNoChildren = (!this.objLayer[i].has_childs);
if (isVisible && hasNoChildren){
- if(this.objLayer[i].checkScale(mapObj)){
+ if(this.objLayer[i].checkScale(mapObj, scale)){
visibleLayers.push(this.objLayer[i].layer_name);
}
}
@@ -373,6 +376,14 @@
}
};
+wms_const.prototype.getLayerByLayerName = function(layername){
+ for(var i=0; i< this.objLayer.length; i++){
+ if(this.objLayer[i].layer_name === layername){
+ return this.objLayer[i];
+ }
+ }
+};
+
/**
* get the current style of the layer
*
@@ -479,6 +490,15 @@
}
return null;
};
+
+wms_const.prototype.getLayerById = function(id){
+ for(var i=0;i<this.objLayer.length;i++){
+ if(parseInt(this.objLayer[i].layer_uid, 10) === parseInt(id,10)) {
+ return this.objLayer[i];
+ }
+ }
+ return null;
+};
/**
* get the state of sublayers from a specified layer
*
@@ -799,9 +819,12 @@
* @type boolean
*/
wms_layer.prototype.checkScale = function(mapObj){
+ var currentScale = parseInt(mapObj.getScale(), 10);
+ if (arguments.length === 2 && arguments[1] !== null) {
+ currentScale = arguments[1];
+ }
var minScale = parseInt(this.gui_layer_minscale, 10);
var maxScale = parseInt(this.gui_layer_maxscale, 10);
- var currentScale = parseInt(mapObj.getScale(), 10);
if(minScale === 0 && maxScale === 0){
return true;
}
Modified: trunk/mapbender/http/plugins/mb_print.js
===================================================================
--- trunk/mapbender/http/plugins/mb_print.js 2010-02-19 10:13:57 UTC (rev 5516)
+++ trunk/mapbender/http/plugins/mb_print.js 2010-02-19 10:22:27 UTC (rev 5517)
@@ -17,7 +17,7 @@
* > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
* > e_mb_mod, e_target, e_requires, e_url) VALUES('<appId>','printPDF',
* > 2,1,'pdf print','Print','div','','',1,1,2,2,5,'',
- * > '<div id="printPDF_working_bg"></div><div id="printPDF_working"><img src="../img/indicator_wheel.gif" style="padding:10px 0 0 10px">Generating PDF</div><div id="printPDF_input"><form id="printPDF_form" action="../print/printFactory.php"><div id="printPDF_selector"></div><div class="print_option"><input type="hidden" id="map_url" name="map_url" value=""/><input type="hidden" id="overview_url" name="overview_url" value=""/><input type="hidden" id="map_scale" name="map_scale" value=""/><input type="hidden" name="measured_x_values" /><input type="hidden" name="measured_y_values" /><br /></div><div class="print_option" id="printPDF_formsubmit"><input id="submit" type="submit" value="Print"><br /></div></form><div id="printPDF_result"></div></div>',
+ * > '<div id="printPDF_working_bg"></div><div id="printPDF_working"><img src="../img/indicator_wheel.gif" style="padding:10px 0 0 10px">Generating PDF</div><div id="printPDF_input"><form id="printPDF_form" action="../print/printFactory.php"><div id="printPDF_selector"></div><div class="print_option"><input type="hidden" id="map_url" name="map_url" value=""/><input type="hidden" id="legend_url" name="legend_url" value=""/><input type="hidden" id="overview_url" name="overview_url" value=""/><input type="hidden" id="map_scale" name="map_scale" value=""/><input type="hidden" name="measured_x_values" /><input type="hidden" name="measured_y_values" /><br /></div><div class="print_option" id="printPDF_formsubmit"><input id="submit" type="submit" value="Print"><br /></div></form><div id="printPDF_result"></div></div>',
* > 'div','../plugins/mb_print.js',
* > '../../lib/printbox.js,../extensions/jquery-ui-1.7.2.custom/development-bundle/external/bgiframe/jquery.bgiframe.min.js,../extensions/jquery.form.min.js',
* > 'mapframe1','','http://www.mapbender.org/index.php/Print');
@@ -286,18 +286,55 @@
var ind = getMapObjIndexByName(myTarget);
var f = jqForm[0];
f.map_url.value = '';
+
+ var scale = f.scale.value || mb_mapObj[ind].getScale();
+ scale = parseInt(scale, 10);
+
+ var legendUrlArray = [];
f.overview_url.value = '';
for(var i=0; i < mb_mapObj[ind].wms.length; i++){
+ var currentWms = mb_mapObj[ind].wms[i];
if(mb_mapObj[ind].wms[i].gui_wms_visible > 0){
- if(mb_mapObj[ind].wms[i].mapURL != false && mb_mapObj[ind].wms[i].mapURL != 'false' && mb_mapObj[ind].wms[i].mapURL != ''){
+ if (mb_mapObj[ind].wms[i].mapURL != false && mb_mapObj[ind].wms[i].mapURL != 'false' && mb_mapObj[ind].wms[i].mapURL != ''){
if(f.map_url.value != ""){
f.map_url.value += '___';
}
- f.map_url.value += mb_mapObj[ind].wms[i].mapURL;
+ f.map_url.value += mb_mapObj[ind].getMapUrl(i, mb_mapObj[ind].getExtentInfos(), scale);
+
+ var wmsLegendObj = [];
+
+ var layers = currentWms.getLayers(mb_mapObj[ind], scale);
+ for (var j = 0; j < layers.length; j++) {
+ var currentLayer = currentWms.getLayerByLayerName(layers[j]);
+ // TODO: add only visible layers
+ var isVisible = (currentLayer.gui_layer_visible === 1);
+ var hasNoChildren = (!currentLayer.has_childs);
+ if (isVisible && hasNoChildren){
+ var layerLegendObj = {};
+ layerLegendObj.name = currentLayer.layer_name;
+ layerLegendObj.title = currentWms.getTitleByLayerName(currentLayer.layer_name);
+ var layerStyle = currentWms.getCurrentStyleByLayerName(currentLayer.layer_name);
+ if (layerStyle === false) {
+ layerStyle = "default";
+ }
+ layerLegendObj.legendUrl = currentWms.getLegendUrlByGuiLayerStyle(currentLayer.layer_name, layerStyle);
+ if (layerLegendObj.legendUrl !== false) {
+ wmsLegendObj.push(layerLegendObj);
+ }
+ }
+ }
+ if (wmsLegendObj.length > 0) {
+ var tmpObj = {};
+ tmpObj[currentWms.wms_currentTitle] = wmsLegendObj;
+ legendUrlArray.push(tmpObj);
+ }
}
}
}
+ f.legend_url.value = $.toJSON(legendUrlArray);
+ updateFormField(formData, "legend_url", f.legend_url.value);
updateFormField(formData, "map_url", f.map_url.value);
+ updateFormField(formData, "scale", scale);
//overview_url
var ind_overview = getMapObjIndexByName('overview');
More information about the Mapbender_commits
mailing list