[Mapbender-commits] r2890 - branches/nimix_dev/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 27 05:46:37 EDT 2008


Author: nimix
Date: 2008-08-27 05:46:37 -0400 (Wed, 27 Aug 2008)
New Revision: 2890

Modified:
   branches/nimix_dev/http/javascripts/tooltip_wms.php
Log:
start on generalizied tooltip module

Modified: branches/nimix_dev/http/javascripts/tooltip_wms.php
===================================================================
--- branches/nimix_dev/http/javascripts/tooltip_wms.php	2008-08-27 09:46:05 UTC (rev 2889)
+++ branches/nimix_dev/http/javascripts/tooltip_wms.php	2008-08-27 09:46:37 UTC (rev 2890)
@@ -19,23 +19,34 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 
+$wfs_conf_filename = "wfs_default.conf";
+include '../include/dyn_php.php';
+$fname = dirname(__FILE__) . "/../../conf/" . $wfs_conf_filename;
+if (file_exists($fname)) {
+	include($fname);
+}
+else {
+	$e = new mb_exception("tooltip.php: Configuration file " . $wfs_conf_filename . " not found.");
+}
+
 echo "var tooltipTarget ='".$e_target[0]."';"; 
 
 include '../include/dyn_js.php';
 ?>
-<?php
-require_once(dirname(__FILE__)."/gg.js");
-?>
+//tolerance when we ask wfs
+var mb_wfs_tolerance = 8;
 
 //destination frame for the request (creates Popup if empty)
 var destFrameName = "";
 var tooltipTime = 1000;
+
 var no_result_text = ["Kein Ergebnis.",'<body onLoad="javascript:window.close()">'];
 var mouseMoves=0;
 var tooltipWin=null;
 var point;
 var tooltipWfsRequestCount = 0;
 var numberOfFinishedWfsRequests = 0;
+var TooltipMsg = {'title':"Informationen"};
 
 //buttonWfs_toDigitize_on ="0";
 
@@ -56,6 +67,8 @@
 function fireRequests(){
 	var ind = getMapObjIndexByName(tooltipTarget);
 	point = new Point(clickX,clickY);
+	var point_geom = new Geometry(geomType.point);
+	point_geom.addPoint(mapToReal(tooltipTarget,point));
 	
 	//FeatureInfo requests
 	urls = mb_mapObj[ind].getFeatureInfoRequests(point);
@@ -65,8 +78,9 @@
 	}
 	
 	//WFS requests
-	requests = getWfsRequests(tooltipTarget, checkscale, filteroption)
+	requests = getWfsRequests(tooltipTarget, point_geom, true);
 	tooltipWfsRequestCount = requests.length;
+	resultGeomArray = new GeometryArray();
 	for(var j=0;j< requests.length;j++){
 		mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,requests[j],function(js_code,status){
 			if (js_code) {
@@ -80,7 +94,7 @@
 	}
 }
 
-function checkFeatureInfoResults(s_code,status){
+function checkFeatureInfoResults(js_code,status){
 	//check if there are results
 	for(var k=0;k < no_result_text.length;k++){
 		if(js_code.indexOf(no_result_text[k])!==-1)
@@ -92,14 +106,18 @@
 }
 
 function checkWfsResultsFinished(g){
+	//check if all wfs requests arrived
 	numberOfFinishedWfsRequests++;
-	if (typeof(geom) == 'object'){
+	if (typeof(g) == 'object'){
 		resultGeomArray.union(g);
 	}
 	if (numberOfFinishedWfsRequests == tooltipWfsRequestCount) {
 		numberOfFinishedWfsRequests = 0;
-		if(resultGeomArray.count()>0)
-			generateWfsResult(resultGeomArray);
+		if(resultGeomArray.count()>0){
+			//generate and output result
+			var html = createWfsResultHtml(resultGeomArray);
+			displayResultDoc(html);
+		}
 	}
 }
 
@@ -130,7 +148,7 @@
 		tooltipWin.destroy();
 
 	//create Popup and append document
-	tooltipWin = new mb_popup({html:'<iframe id="tooltipWin" name="tooltipWin" src="about:blank"/>',title:"Feature Info",width:270,height:200,balloon:true,left:x,top:y});
+	tooltipWin = new mb_popup({html:'<iframe id="tooltipWin" name="tooltipWin" src="about:blank"/>',title:TooltipMsg.title,width:270,height:200,balloon:true,left:x,top:y});
 	$("#"+tooltipWin.id+" iframe").each(function(){
 	    var oDoc = this.contentWindow || this.contentDocument;
 	    if (oDoc.document) {
@@ -147,6 +165,8 @@
 	//get all configurations
 	wfs_config = get_complete_wfs_conf();
 	var ind = getMapObjIndexByName(target);
+	var db_wfs_conf_id = [];
+	var js_wfs_conf_id = [];
 	
 	//search configurations that are selected (and in scale)
 	for (var i=0; i < mb_mapObj[ind].wms.length; i++){
@@ -195,3 +215,84 @@
 	
 	return requests;
 }
+
+function createWfsResultHtml(_geomArray){
+	var geometryIndex = 0;
+	wfsConf = get_complete_wfs_conf();
+	var html = "<table style='background-color:#EEEEEE;'>\n";
+	if(_geomArray.count()>1){
+		for (var i = 0 ; i < _geomArray.count(); i ++) {
+			if (_geomArray.get(i).get(-1).isComplete()) {
+				html += "\t<tr>\n\t\t<td style = 'color:blue;font-size:12px;cursor:pointer;'\n";
+//				html += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
+//				html += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
+//				html += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+				var geomName = getWfsListEntry(_geomArray.get(i)); 
+				html += ">" + geomName +"</td>";
+				html += "\t\t</tr>\n"; 
+			}
+		}
+	}
+	else{
+		var wfsConfIndex = _geomArray.get(geometryIndex).wfs_conf;
+		var currentWfsConf = wfsConf[wfsConfIndex];
+		for (var i = 0 ; i <currentWfsConf.element.length; i ++) {
+		    if(currentWfsConf.element[i].f_show_detail==1){
+		    	if( _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name)!=false){
+					html +="<tr><td>\n"; 
+					html += currentWfsConf.element[i].f_label;
+					html +="</td>\n"; 
+					html += "<td>\n";
+					var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name); 
+					if(currentWfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+						var setUrl = currentWfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+elementVal+"' target='_blank'");
+						if(setUrl.match(/><\/a>/)){
+							var newLink	=	setUrl.replace(/><\/a>/, ">"+elementVal+"</a>");
+						}
+						else{
+							var newLink = setUrl;
+						}
+/*						if(openLinkFromSearch=='1'){
+							window.open(elementVal, elementVal,"width=500, height=400,left=100,top=100,scrollbars=yes");
+						}		
+*/						html +=  newLink;
+					}
+					else{
+						html += elementVal;
+					}
+					html += "</td></tr>\n";		
+				}
+			}
+		}
+	}
+	html += "</table>\n";
+	return html;
+}
+
+function getWfsListEntry (geom) {
+	wfsConfId = geom.wfs_conf;
+	wfsConf = window.frames["wfs_conf"].get_wfs_conf();
+	if (typeof(wfsConfId) == "number" && wfsConfId >=0 && wfsConfId < wfsConf.length) {
+		var resultArray = [];
+		for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
+			if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1 && geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) !=false) {
+				var pos = wfsConf[wfsConfId]['element'][i]['f_respos'];
+				if (typeof(resultArray[pos]) != "undefined") {
+					resultArray[pos] += " " + geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+				}
+				else {
+					resultArray[pos] = geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+				} 
+			}
+		}
+		var resultName = resultArray.join(" ");
+		if (resultName == "") {
+			resultName = wfsConf[wfsConfId]['g_label'];
+		}
+		return resultName;
+	}
+	else {
+		return false;
+	}
+}
+



More information about the Mapbender_commits mailing list