[Mapbender-commits] r1710 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Oct 5 07:54:23 EDT 2007


Author: verenadiewald
Date: 2007-10-05 07:54:22 -0400 (Fri, 05 Oct 2007)
New Revision: 1710

Modified:
   trunk/mapbender/http/javascripts/mod_legend.php
Log:
new functions for gui layer style handling

Modified: trunk/mapbender/http/javascripts/mod_legend.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_legend.php	2007-10-05 11:47:02 UTC (rev 1709)
+++ trunk/mapbender/http/javascripts/mod_legend.php	2007-10-05 11:54:22 UTC (rev 1710)
@@ -64,6 +64,7 @@
 
 <script type="text/javascript">
 <!--
+
 mod_legend_offsetLeft = 25;
 mod_legend_offsetTop = -10;
 
@@ -80,10 +81,9 @@
 catch(e){
 	stickylegend = 'false';
 }
+// Todo: return-value may change in the next version....
+parent.mb_registerSubFunctions("window.frames['legend'].mod_legend_pos(frameName)");
 
-parent.mb_registerSubFunctions("window.frames['legend'].mod_legend_pos()");
-
-
 function mod_legend_init(){
 	var obj = parent.document.getElementById("legend");
 	obj.style.top = mod_legend_target_top  + mod_legend_offsetTop;
@@ -95,127 +95,83 @@
 		checkobj.style.height = 0;
 	}
 }
+
 function mod_legend_repaint(obj){
 	var checkobj = document.getElementById("checkboxstyle");
 	if(checkobj.style.visibility == "visible"){
 		mod_legend_pos();     
 	}
 }
-function mod_legend_pos(){
-	var ind = parent.getMapObjIndexByName(mod_legend_target);
-	var obj = parent.document.getElementById("legend");
 
-	if(stickylegend == 'true'){
-		obj.style.left = parseInt(parent.mb_mapObj[ind].width) + mod_legend_target_left + mod_legend_offsetLeft;
-	}
-
-	if(document.forms[0].sw.checked ==  false){
-		parent.writeTag("legend", "leg", "");
-		return true;
-	}
-
-	var layers;
-	var str = "";
-	var str_tmp = "";
-
-	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
-   		var img_format = parent.mb_mapObj[ind].wms[i].gui_wms_mapformat;
-		//if(parent.mb_mapObj[ind].wms[i].wms_getlegendurl != ""){
-		if(parent.mb_mapObj[ind].wms[i].gui_wms_visible != 0){
-			layers = parent.mb_checkScale(mod_legend_target,ind,i);
-			
-			if(layers[0] != ""){   				    
-				var layer = layers[0].split(",");
-				var titles = layers[2].split(",");
-				var legendurl = layers[3].split(",");
-				var layerparent= layers[4].split(",");
-				var tmp_name = "";
+function mod_legend_pos(frameName){
+	if(frameName == mod_legend_target){
+		var ind = parent.getMapObjIndexByName(mod_legend_target);
+		var obj = parent.document.getElementById("legend");
 	
-        		
-				for(var j=0; j<layer.length; j++){
-				
-		    		var l = parent.mb_getchildsbyname(ind,i,layer[j]);
-    	    		
-		    		// handle grouped layers
-				 	if (l) {				  		
-          				for (var k=0; k<l["name"].length; k++){
-          					//str_tmp += l["title"][k]; // ------
-          					
-          					
-          					if (l["legendurl"][k]!='' && l["legendurl"][k]!=0){
-					 			if (tmp_name != l["title"][k]) {
-					 				if (showgroupedlayertitle == 'true'){				
-				  						str_tmp += "<div><span class='titles'>" +l["title"][k]+ "</span></div>";
-				  					}
-				 	  				str_tmp += "<div>";
-				 	  				if(legendlink == 'true'){
-                                		str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layer[j]+l["name"][k]+"' class='legendlink' title='Zeigt Liste zum Thema: "+titles[j]+"' target='result'>";
-                                	}
-                                	str_tmp += "<img border=0 src = '";			
-					  				str_tmp += l["legendurl"][k];
-					  				str_tmp += "'></img>";		
-					  				//str_tmp += l["legendurl"][k];
-					  				if (legendlink == 'true'){
-                                		str_tmp += "</a>";
-                                	}
-                                	str_tmp += "</div>"; 
-									tmp_name = l["title"][k];
-					 			}	// if
-					 		} // if legendurl
-         				 } // for var k=0
-         			} // if (l)         
-         			else {
-         				if (legendurl[j]!='' && legendurl[j]!=0){
-         					if(layerparent[j] == 0){
-	         					if(showlayertitle == 'true'){
-									str_tmp += "<div><span class='titles'>" + titles[j]+ "</span></div>";
-								}
-								str_tmp += "<div>";
-	                        	if(legendlink == 'true'){
-	                        		str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layer[j]+"' class='link_metadata' title='Zeigt Liste zum Thema: "+titles[j]+"' target='result'>";
-	                        	}
-	                        	str_tmp += "<img border=0 src = '";			
-								str_tmp += legendurl[j];
-								
-								str_tmp += "'></img>";
-							
-								//str_tmp += "legend:"+legendurl[j];
-								if (legendlink == 'true'){
-	                        		str_tmp += "</a>";
-	                        	}
-	                        	str_tmp += "</div>";
-                        	}//layerparent
-                        } // legendurl[j]!='' && legendurl[j]!=0
-					} // else
-					
-
-					
-					
-				}// for
-			} // if (layers[0...       
-		//}     // if (parent.mb_mapObj[ind].wms[i].wms_getlegendurl != "")
+		if(stickylegend == 'true'){
+			obj.style.left = parseInt(parent.mb_mapObj[ind].width) + mod_legend_target_left + mod_legend_offsetLeft;
 		}
-					
-					if(str_tmp !=''){
-  		  		if (showwmstitle == 'true'){
-    					str += "<div><span class='header'>" +parent.mb_mapObj[ind].wms[i].wms_title+ "</span></div>";
-    				} 
-						str += str_tmp;
-						//prompt('',str_tmp);
-						str_tmp ='';
-					}	
+	
+		if(document.forms[0].sw.checked ==  false){
+			parent.writeTag("legend", "leg", "");
+			return true;
+		}
 		
-	}// for
-    
-	if(str != ""){
-		parent.writeTag("legend", "leg", str);
-		//prompt('',str);
+		var str = "";
+		var str_tmp = "";
+						
+		for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
+			
+			 	var layerNames = parent.mb_mapObj[ind].wms[i].getLayers(parent.mb_mapObj[ind]);
+				for(var j=0; j<layerNames.length; j++){
+					var layerParent = parent.mb_mapObj[ind].wms[i].checkLayerParentByLayerName(layerNames[j]); 
+					var layerTitle = parent.mb_mapObj[ind].wms[i].getTitleByLayerName(layerNames[j]);
+					var layerStyle = parent.mb_mapObj[ind].wms[i].getCurrentStyleByLayerName(layerNames[j]);
+					if(layerStyle==false){
+						var legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],"default");	
+					}
+					else{
+						var legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],layerStyle);
+					}
+					//console.log("layer_infos : %s",layerNames[j],"---",layerParent,"---",layerTitle,"---",layerStyle,"---",legendUrl);
+			         
+					if (legendUrl!='' && legendUrl!=0){
+	 					//if(layerParent == 0){
+	 						if(showlayertitle == 'true'){
+								str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
+							}
+							str_tmp += "<div>";
+	                    	if(legendlink == 'true'){
+	                    		str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layerNames[j]+"' class='link_metadata' title='Zeigt Liste zum Thema: "+layerTitle+"' target='result'>";
+	                    	}
+	                    	str_tmp += "<img border=0 src = '";			
+							str_tmp += legendUrl;
+							str_tmp += "'></img>";
+							if (legendlink == 'true'){
+	                    		str_tmp += "</a>";
+	                    	}
+	                    	str_tmp += "</div>";
+	                	//}
+	               } 
+				}
+			if(str_tmp !=''){
+				if (showwmstitle == 'true'){
+					str += "<div><span class='header'>" +parent.mb_mapObj[ind].wms[i].wms_title+ "</span></div>";
+				}
+				str += str_tmp;
+				str_tmp ='';
+			}		
+		}
+		//console.log("ind =%s",ind,"str =",str);
+	    if(str != ""){
+			parent.writeTag("legend", "leg", str);
+		}
+		else{
+			parent.writeTag("legend", "leg", "");
+		}
+		return true;
 	}
-	else{
-		parent.writeTag("legend", "leg", "");
-	}
-	return true;
-} // function mod_legend_pos()
+} 
 
 // -->
 </script>



More information about the Mapbender_commits mailing list