[Mapbender-commits] r3210 - branches/beck_dev/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Nov 10 08:43:49 EST 2008
Author: beck
Date: 2008-11-10 08:43:49 -0500 (Mon, 10 Nov 2008)
New Revision: 3210
Added:
branches/beck_dev/http/javascripts/tooltip.php
branches/beck_dev/http/javascripts/tooltip24.php
Modified:
branches/beck_dev/http/javascripts/popup.js
Log:
Modified: branches/beck_dev/http/javascripts/popup.js
===================================================================
--- branches/beck_dev/http/javascripts/popup.js 2008-11-10 13:43:12 UTC (rev 3209)
+++ branches/beck_dev/http/javascripts/popup.js 2008-11-10 13:43:49 UTC (rev 3210)
@@ -4,7 +4,7 @@
* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
*/
//http://www.mapbender.org/index.php/popup
-var popup_count = 1;
+var popup_count = 0;
var popup_top = 150;
/**
@@ -37,7 +37,6 @@
* resizeable: allow user to change the size default:true
* dragable: allow user to move the window default:true
* balloon: balloon popup from top, left (disables resizeable and dragable)
- * modal: create modal popup default:false
*
* @param {String} html the "body" of the popup, can also be "url:http://foo.de" to display a website
* @param {Number} width width of the popup
@@ -55,8 +54,8 @@
break;
}
- this.id="popup"+String(++popup_top);
-
+ this.id="popup"+String(create_pos);
+
//Set defaults
defaults = {
left:25*create_pos,
@@ -66,13 +65,13 @@
frameName:this.id,
id:this.id
};
-
+
if(typeof(title)!='object'){
this.options = defaults;
//Set vars
if(posx)this.options.left=posx;
- if(posy)this.options.top=posy;
+ if(posy)this.options.top=posx;
if(width)this.options.width=width;
if(height)this.options.height=height;
if(title)this.options.title=title;
@@ -88,8 +87,6 @@
else
this.options=$.extend(defaults, title);
- this.id = this.options.id;
-
popup_count++;
//create dom popup
@@ -116,7 +113,6 @@
mb_popup.prototype.hide = function(){
$("#"+this.id).hide();
$("#balloon_"+this.id).hide();
- $("#modal_mouse_catcher").remove();
}
/**
@@ -125,7 +121,6 @@
mb_popup.prototype.destroy = function(){
$("#"+this.id).remove();
$("#balloon_"+this.id).remove();
- $("#modal_mouse_catcher").remove();
}
/**
@@ -195,43 +190,10 @@
mb_popup.prototype.setHtml = function(htmll){
this.options.url=null;
this.options.html=htmll;
- $("#"+this.id+" .Content").html('<div class="scrollDiv">'+htmll+'</div>');
+ $("#"+this.id+" .jqmnContent").html(htmll);
}
-/**
- * behaves like document.open(); (clear popup)
- */
-mb_popup.prototype.open = function(){
- oDoc = this.getDocument();
- if(oDoc!=null){
- return oDoc.open();
- }
- this.setHtml("");
-}
/**
- * behaves like document.write(); (appends content to the popup)
- *
- * @param {String} text or html to write into the document
- */
-mb_popup.prototype.write = function(str){
- oDoc = this.getDocument();
- if(oDoc!=null){
- return oDoc.write(str);
- }
- this.setHtml(this.options.html+str);
-}
-
-/**
- * behaves like document.close(); (finish loading state if popup is an iframe)
- */
-mb_popup.prototype.close = function(){
- oDoc = this.getDocument();
- if(oDoc!=null){
- return oDoc.close();
- }
-}
-
-/**
* sets the url of the content
*
* @param {String} url new url of the popup
@@ -239,24 +201,14 @@
mb_popup.prototype.setUrl = function(url){
this.options.url=url;
this.options.html=null;
-
- oDoc = this.getDocument();
- if(oDoc){
- oDoc.location.href = url;
+ try{
+ eval("window.frames."+this.options.frameName+".location = \""+url+"\"");
+ }catch(e){
+ $("#"+this.id+" .jqmnContent").html('<iframe src="'+url+'"></iframe>');
}
- else{
- $("#"+this.id+" .Content").html('<iframe src="'+url+'"></iframe>');
- }
}
/**
- * reposition
- */
-mb_popup.prototype.reposition =function(){
-//TODO
-}
-
-/**
* gets the visible state of the popup window
* @return visible state of the popup
* @type Boolean
@@ -266,34 +218,6 @@
}
/**
- * (re) set Some Options of the popup Window and rerender it
- * @param options object that contains the new options
- */
-mb_popup.prototype.set = function(options){
- this.destroy();
- this.options=$.extend(this.options, options);
- this.show();
-}
-
-/**
- * get the DOM document of the client iframe
- * @return DOM document or null if the popup doesn't contain an iframe
- */
-mb_popup.prototype.getDocument = function(){
- iFrame = $("#"+this.id+" iframe")[0];
- try{
- //try to load contentWindow first since not every browser
- //supports contentDocument (or gives the window instead)
- oDoc = iFrame.contentWindow || iFrame.contentDocument;
- if (oDoc.document) {
- oDoc = oDoc.document;
- }
- return oDoc;
- }
- catch(e){return null;}
-}
-
-/**
* get Scroll position
*/
function getScrollPos() {
@@ -315,8 +239,6 @@
return scrOf;
}
-
-
(function($){
$.fn.mbPopup = function(options){
//default settings
@@ -329,72 +251,82 @@
minTop:"document",minLeft:"document",
maxRight:false,maxBottom:false,
dragable:true,resizeable:true,balloon:false,
- style:null,destroy:true,modal:false,
+ style:null,destroy:true,
closeCallback:null
};
//override defaults
settings=$.extend(defaults,options)
- this.settings = settings;
-
+
//add Styles
- this.addClass("mbPopup");
+ this.addClass("jqmNotice");
- //append additions styles
- if(settings.style)
- this.css(settings.style);
-
//automated settings for balloon popup
if(settings.balloon){
- $("body").append("<div id='balloon_"+settings.id+"' class='balloonBL' style='visibility:hidden;'>");
+ var dim = getScrollPos();
+
+ bubble_height = 80;
+ bubble_width = 100;
settings.resizeable = false;
settings.dragable = false;
- }
+ settings.hotSpotY=settings.top;
+ settings.hotSpotX=settings.left;
+ position = 0;
+
+ console ={};
+ console.log = function(){};
+
+ if(settings.hotSpotY-settings.height-bubble_height-parseInt(this.css("border-top-width"))<dim.Y){
+ //bubble on top
+ settings.top = settings.hotSpotY+bubble_height-parseInt(this.css("border-top-width"));
+ }
+ else{
+ //bubble on bottom
+ settings.top = settings.hotSpotY-settings.height-bubble_height+(top.ie?parseInt(this.css("border-bottom-width")):-parseInt(this.css("border-top-width")));
+ position+=2;
+ }
+ if(settings.hotSpotX+settings.width+parseInt(this.css("border-left-width"))+parseInt(this.css("border-right-width"))>(dim.X+dim.wW)){
+ //bubble on right
+ settings.left = settings.hotSpotX-parseInt(this.css("border-left-width"))-parseInt(this.css("border-right-width"))-settings.width;
+ position++;
+ }
+ else{
+ //bubble on left
+ settings.left = settings.hotSpotX-parseInt(this.css("border-left-width"));
+ }
- //calculate positioning (mainly needed for balloon style)
- pos = $.mbPopupFn.calcPositioning(settings, this);
-
- //set balloon arm position
- if(settings.balloon){
- $("#balloon_"+settings.id).attr("class", "balloon"+(pos.position>=2?"B":"T")+(pos.position%2?"R":"L"))
- .css({"z-index":(popup_top),visibility:"visible",left:String(pos.bX)+"px",top:String(pos.bY)+"px"});
- settings.left = pos.pX;
- settings.top = pos.pY;
+ $("body").append("<div id='balloon_"+settings.id+"' class='balloon"+(position>=2?"B":"T")+(position%2?"R":"L")+"' style='z-index:"+(popup_top++)+";left:"+(settings.hotSpotX-(position%2?bubble_width:0))+"px;top:"+(settings.hotSpotY-(position>=2?bubble_height:0))+"px'>");
}
- //fix IE width and height by adding the padding values
- if($.browser.msie){
- settings.width = pos.pW;
- settings.height = pos.pH;
- }
-
- //Set dimensions
- this.css({top:String(settings.top)+"px",
- left:String(settings.left)+"px",
- width:String(settings.width)+"px",
- height:String(settings.height)+"px",
+ this.css({top:settings.top+"px",
+ left:settings.left+"px",
+ width:settings.width+"px",
+ height:settings.height+"px",
opacity:settings.opacity
});
+ if(settings.style)
+ this.css(settings.style);
+
//Insert content
if(settings.url)
html = ('<iframe name="'+settings.frameName+'" src="'+settings.url+'"></iframe>');
else
html = ('<div class="scrollDiv">'+settings.html+'</div>');
- this.html('<div class="Title Drag"><h1>'+settings.title+'</h1></div><div class="Content">'+html+'</div><img src="../img/close_icon.png" class="Close" alt="close" />'+(settings.resizeable?'<div class="Resize" />':''));
+ this.html('<div class="jqmnTitle jqDrag"><h1>'+settings.title+'</h1></div><div class="jqmnContent">'+html+'</div><img src="../img/close_icon.png" class="jqmClose" alt="close" />'+(settings.resizeable?'<div class="jqResize" />':''));
var data = {El:this,fY:settings.minTop,fX:settings.minLeft,tX:settings.maxRight,tY:settings.maxBottom,
fW:settings.minWidth,tW:settings.maxWidth,fH:settings.minHeight,tH:settings.maxHeight,
destroy:settings.destroy,opacity:settings.opacity,moveOpacity:settings.moveOpacity,close:settings.closeCallback}
-
+
//Make window Dragable
if(settings.dragable)
- $(".Drag", this).bind('mousedown',data,function(event){
+ $(".jqDrag", this).bind('mousedown',data,function(event){
//set to top
event.data.El.css("z-index",popup_top++);
event.data.El.css('opacity',event.data.moveOpacity)
//create helper div to steal mouse events
- $("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top+2)+($.browser.msie?";background:url(../img/transparent.gif)":"")+"\" id=\"mouse_catcher\"></div>");
+ $("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top+2)+(top.ie?";background:url(../img/transparent.gif)":"")+"\" id=\"mouse_catcher\"></div>");
$("iframe", event.data.El).hide();
//Parse setiings of min and max position
@@ -406,12 +338,12 @@
//Make Window resizable
if(settings.resizeable)
- $(".Resize", this).bind('mousedown',data,function(event){
+ $(".jqResize", this).bind('mousedown',data,function(event){
//set to top
event.data.El.css("z-index",popup_top++);
- event.data.El.css('opacity',event.data.moveOpacity)
+ event.data.El.css('opacity',0.8)
//create helper div to steal mouse events
- $("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top+2)+($.browser.msie?";background:url(../img/transparent.gif)":"")+"\" id=\"mouse_catcher\"></div>");
+ $("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top+2)+(top.ie?";background:url(../img/transparent.gif)":"")+"\" id=\"mouse_catcher\"></div>");
$("iframe", event.data.El).hide();
//Parse setiings of min and max position
@@ -422,10 +354,9 @@
});
//closeButton
- this.closePopup = function(event){
+ $(".jqmClose", this).bind('click',data, function(event){
if(event.data.close)
event.data.close();
- $("#modal_mouse_catcher").remove();
if(event.data.destroy){
event.data.El.slideUp('slow', function(){$(this).remove();});
$("#balloon_"+event.data.El.attr("id")).remove();
@@ -434,15 +365,8 @@
event.data.El.slideUp('slow');
$("#balloon_"+event.data.El.attr("id")).fadeOut();
}
- };
- $(".Close", this).bind('click',data, this.closePopup);
+ });
- //create div to make window modal
- if(settings.modal){
- $("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top-1)+($.browser.msie?";background:url(../img/transparent.gif)":"")+"\" id=\"modal_mouse_catcher\"></div>");
- $("#modal_mouse_catcher").bind('click',data, this.closePopup);
- }
-
//raise on click
this.click(function(){this.style.zIndex=popup_top++;$("#balloon_"+this.id).css("z-index", popup_top++);});
$("#balloon_"+settings.id).click(function(){$("#"+this.id.substr(8)).css("z-index", popup_top++);this.style.zIndex=popup_top++;});
@@ -518,42 +442,6 @@
if(ret.tX)ret.tX-=bd.X;
if(ret.tY)ret.tY-=bd.Y;
return ret;
- },
- calcPositioning:function(settings, el){
- var dim = getScrollPos();
-
- pos = {};
- pos.pH = settings.height + (parseInt(el.css("padding-top"))+parseInt(el.css("padding-bottom")));
- pos.pW = settings.width + (parseInt(el.css("padding-left"))+parseInt(el.css("padding-right")));
- if(settings.balloon){
- pos.bH = $("#balloon_"+settings.id).height();
- pos.bW = $("#balloon_"+settings.id).width();
-
- pos.position = 0;
-
- if(settings.top-pos.pH-pos.bH-parseInt(el.css("border-top-width"))<dim.Y){
- //bubble on top
- pos.pY = settings.top+pos.bH-parseInt(el.css("border-top-width"));
- }
- else{
- //bubble on bottom
- pos.pY = settings.top-pos.pH-pos.bH+($.browser.msie?parseInt(el.css("border-bottom-width")):-parseInt(el.css("border-top-width")));
- pos.position+=2;
- }
- if(settings.left+pos.pW+parseInt(el.css("border-left-width"))+parseInt(el.css("border-right-width"))>(dim.X+dim.wW)){
- //bubble on right
- pos.pX = settings.left-parseInt(el.css("border-left-width"))-parseInt(el.css("border-right-width"))-pos.pW;
- pos.position++;
- }
- else{
- //bubble on left
- pos.pX = settings.left-parseInt(el.css("border-left-width"));
- }
-
- pos.bX=(settings.left-(pos.position%2?pos.bW:0));
- pos.bY=(settings.top-(pos.position>=2?pos.bH:0));
- }
- return pos;
}
};
})
Added: branches/beck_dev/http/javascripts/tooltip.php
===================================================================
--- branches/beck_dev/http/javascripts/tooltip.php (rev 0)
+++ branches/beck_dev/http/javascripts/tooltip.php 2008-11-10 13:43:49 UTC (rev 3210)
@@ -0,0 +1,272 @@
+<?php
+# $Id: mod_toggleModule.php 2238 2008-03-13 14:24:56Z christoph $
+# http://www.mapbender.org/index.php/mod_toggleModule.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.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';
+?>
+
+var mb_wfs_tolerance = 20;
+var tooltipTime = 500;
+
+var mouseMoves=0;
+var tooltipWin=null;
+var point;
+var numberOfFinishedAjaxCalls = 0;
+buttonWfs_toDigitize_on ="0";
+
+function mod_tooltipInit(){
+ $(window.frames["mapframe1"].document).mousemove(function(event){
+ mod_tooltip_run();
+ mb_getMousePos(event,"mapframe1");
+ }).mouseout(function(){mouseMoves=0;});
+}
+
+mb_registerInitFunctions("mod_tooltipInit();");
+
+function mod_tooltip_run(){
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ mouseMoves++;
+ setTimeout("if(mouseMoves=="+mouseMoves+")requestWfs();",tooltipTime);
+}
+
+function showWMSBalloon(){
+ x=clickX+parseInt(document.getElementById("mapframe1").style.left);
+ y=clickY+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ var ind = getMapObjIndexByName("mapframe1");
+ req = mb_mapObj[ind].getFeatureInfoRequests({x:clickX,y:clickY});
+ if(req)
+ tooltipWin = new mb_popup({url:req[0],title:"Feature Info",width:270,height:200,balloon:true,left:x,top:y});
+ tooltipWin.show();
+}
+
+function showWFSBalloon(geom){
+ x=point.x+parseInt(document.getElementById("mapframe1").style.left);
+ y=point.y+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ tooltipWin = new mb_popup({title:searchPopupTitle,html:createListOfGeometries(),width:270,height:150,balloon:true,left:x,top:y});
+ tooltipWin.show();
+}
+
+function requestWfs(){
+ point = new Point(clickX, clickY);
+
+ var ind = getMapObjIndexByName("mapframe1");
+ var db_wfs_conf_id = [];
+ js_wfs_conf_id = [];
+ _geomArray = new GeometryArray();
+
+ wfs_config = window.frames["wfs_conf"].get_wfs_conf();
+ for (var i=0; i<mb_mapObj[ind].wms.length; i++){
+ for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ var o = mb_mapObj[ind].wms[i].objLayer[ii];
+ if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+ if(o.checkScale(mb_mapObj[ind]))
+ db_wfs_conf_id[db_wfs_conf_id.length] = o.gui_layer_wfs_featuretype;
+ }
+ }
+ }
+ for(var i=0; i<db_wfs_conf_id.length; i++){
+ for(var ii=0; ii<wfs_config.length; ii++){
+ if(wfs_config[ii]['wfs_conf_id'] == db_wfs_conf_id[i]) js_wfs_conf_id[js_wfs_conf_id.length] = ii;
+ }
+ }
+
+ numberOfAjaxCalls_ = js_wfs_conf_id.length;
+
+
+
+ var buffer = mb_wfs_tolerance/2;
+ var mapPosXAddPix = clickX + buffer;
+ var mapPosYAddPix = clickY + buffer;
+ var mapPosXRemovePix = clickX - buffer;
+ var mapPosYRemovePix = clickY - buffer;
+ var realWorld1 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+ var realWorld2 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld3 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld4 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+ for(var i=0; i<js_wfs_conf_id.length; i++){
+ var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
+ param = "service=wfs&request=getFeature&version=1.0.0&typename="+ wfs_config[js_wfs_conf_id[i]]['featuretype_name']+"&filter=";
+ var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>";
+ filter += "<Intersects><ogc:PropertyName>";
+ for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
+ if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
+ filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+ }
+ }
+ filter += "</ogc:PropertyName><gml:Polygon srsName='4326'><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ filter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ filter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></ogc:Filter>";
+ url += param;
+ mb_get_geom_(url, filter, i, wfs_config[js_wfs_conf_id[i]]['featuretype_name'], js_wfs_conf_id[i], db_wfs_conf_id[i]);
+ }
+ return true;
+}
+function mb_get_geom_(url, filter, index, typename, js_wfs_conf_id, db_wfs_conf_id) {
+
+ mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,{'url':url,'filter':filter,'typename':typename,'js_wfs_conf_id':js_wfs_conf_id, 'db_wfs_conf_id':db_wfs_conf_id},function(js_code,status){
+ if (js_code) {
+ eval(js_code);
+ }
+ if (typeof(geom) == "undefined") {
+ var geom = new GeometryArray();
+ }
+ checkIfAllAjaxCallsFinished_(geom);
+ });
+}
+
+function checkIfAllAjaxCallsFinished_ (geom) {
+ numberOfFinishedAjaxCalls++;
+ if (typeof(geom) == 'object'){
+ _geomArray.union(geom);
+ }
+ if (numberOfFinishedAjaxCalls == numberOfAjaxCalls_) {
+ numberOfFinishedAjaxCalls = 0;
+ if(_geomArray.count()>0)
+ showWFSBalloon(_geomArray);
+ }
+}
+
+function createListOfGeometries(){
+ if(_geomArray.count()>0){
+ var listOfGeom = "<table style='background-color:#EEEEEE;'>\n";
+ if (_geomArray.count() > 0) {
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<tr><td style='color:black;font-size:12px;'>edit all</td>\n";
+ listOfGeom += "<td><img title='edit all' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryArrayToDigitize(_geomArray);'></img>";
+ listOfGeom += "</td>\n</tr>\n";
+ listOfGeom += "<tr>\n<td> </td>\n</tr>\n";
+ }
+ for (var i = 0 ; i < _geomArray.count(); i ++) {
+ if (_geomArray.get(i).get(-1).isComplete()) {
+ listOfGeom += "\t<tr>\n\t\t<td style = 'color:blue;font-size:12px;cursor:pointer;'\n";
+ listOfGeom += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
+ listOfGeom += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
+ listOfGeom += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+ var geomName = getListTitle(_geomArray.get(i));
+ //if (_geomArray.get(i).geomType == geomType.polygon) {geomName += "(polygon)";}
+ //else if (_geomArray.get(i).geomType == geomType.line) {geomName += "(line)";}
+ //else if (_geomArray.get(i).geomType == geomType.point) {geomName += "(point)";}
+ listOfGeom += ">" + geomName +"</td>";
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<td><img title='edit geometry object' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryToDigitize("+i+");'></img></td>";
+ }
+ listOfGeom += "\t\t</tr>\n";
+ }
+ }
+ }
+ listOfGeom += "</table>\n";
+ return listOfGeom;
+ }
+ else{
+ geometryIndex = 0;
+ wfsConf = get_complete_wfs_conf();
+ var wfsConfIndex = _geomArray.get(0).wfs_conf;
+ var currentWfsConf = wfsConf[wfsConfIndex];
+
+ var resultHtml = "";
+ resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+ 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){
+ //console.log(currentWfsConf.element[i].element_name+"---"+currentWfsConf.element[i].f_respos);
+ resultHtml +="<tr><td>\n";
+ resultHtml += currentWfsConf.element[i].f_label;
+ resultHtml +="</td>\n";
+ resultHtml += "<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");
+ }
+ resultHtml += newLink;
+ }
+ else{
+ resultHtml += elementVal;
+ }
+ resultHtml += "</td></tr>\n";
+ }
+ }
+ }
+ resultHtml += "</table>\n";
+ return resultHtml;
+ }
+}
+
+function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
+ return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
+}
+
+function Numsort (a, b) {
+ return a - b;
+}
+
+function getListTitle (geom) {
+ wfsConfId = geom.wfs_conf;
+ wfsConf = window.frames["wfs_conf"].get_wfs_conf();
+ if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
+ var resultArray = [];
+ var resultName = "";
+ 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']);
+ }
+ resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
+ }
+ }
+ resultArray.sort(Numsort);
+ var resultName = resultArray.join(" ");
+ if (resultName == "") {
+ resultName = wfsConf[wfsConfId]['g_label'];
+ }
+ return resultName;
+ }
+ else {
+ return msgObj.digitizeDefaultGeometryName;
+ }
+}
Added: branches/beck_dev/http/javascripts/tooltip24.php
===================================================================
--- branches/beck_dev/http/javascripts/tooltip24.php (rev 0)
+++ branches/beck_dev/http/javascripts/tooltip24.php 2008-11-10 13:43:49 UTC (rev 3210)
@@ -0,0 +1,278 @@
+<?php
+# $Id: mod_toggleModule.php 2238 2008-03-13 14:24:56Z christoph $
+# http://www.mapbender.org/index.php/mod_toggleModule.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.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';
+?>
+
+var mb_wfs_tolerance = 20;
+var tooltipTime = 500;
+
+var mouseMoves=0;
+var tooltipWin=null;
+var point;
+var numberOfFinishedAjaxCalls = 0;
+buttonWfs_toDigitize_on ="0";
+
+function mod_tooltipInit(){
+ $(window.frames["mapframe1"].document).mousemove(function(event){
+ mod_tooltip_run();
+ mb_getMousePos(event,"mapframe1");
+ }).mouseout(function(){mouseMoves=0;});
+}
+
+mb_registerInitFunctions("mod_tooltipInit();");
+
+function mod_tooltip_run(){
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ mouseMoves++;
+ setTimeout("if(mouseMoves=="+mouseMoves+")requestWfs();",tooltipTime);
+}
+
+function showWMSBalloon(){
+ x=clickX+parseInt(document.getElementById("mapframe1").style.left);
+ y=clickY+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ var ind = getMapObjIndexByName("mapframe1");
+ req = mb_mapObj[ind].getFeatureInfoRequests({x:clickX,y:clickY});
+ if(req)
+ tooltipWin = new mb_popup({url:req[0],title:"Feature Info",width:270,height:200,balloon:true,left:x,top:y});
+ tooltipWin.show();
+}
+
+function showWFSBalloon(geom){
+ x=point.x+parseInt(document.getElementById("mapframe1").style.left);
+ y=point.y+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ tooltipWin = new mb_popup({title:searchPopupTitle,html:createListOfGeometries(),width:270,height:150,balloon:true,left:x,top:y});
+ tooltipWin.show();
+}
+
+function requestWfs(){
+ point = new Point(clickX, clickY);
+
+ var ind = getMapObjIndexByName("mapframe1");
+ var db_wfs_conf_id = [];
+ js_wfs_conf_id = [];
+ _geomArray = new GeometryArray();
+
+ wfs_config = window.frames["wfs_conf"].get_wfs_conf();
+ for (var i=0; i<mb_mapObj[ind].wms.length; i++){
+ str_LayerStyles=mb_checkScale("mapframe1",ind,i);
+ arr_layers = str_LayerStyles[0].split(",");
+ for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ var o = mb_mapObj[ind].wms[i].objLayer[ii];
+ if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+ for(iii=0;iii<arr_layers.length;iii++){
+ if(o.layer_name == arr_layers[iii]){
+ db_wfs_conf_id[db_wfs_conf_id.length] = o.gui_layer_wfs_featuretype;
+ break;
+ }
+ }
+ }
+ }
+ }
+ for(var i=0; i<db_wfs_conf_id.length; i++){
+ for(var ii=0; ii<wfs_config.length; ii++){
+ if(wfs_config[ii]['wfs_conf_id'] == db_wfs_conf_id[i]) js_wfs_conf_id[js_wfs_conf_id.length] = ii;
+ }
+ }
+
+ numberOfAjaxCalls_ = js_wfs_conf_id.length;
+
+
+
+ var buffer = mb_wfs_tolerance/2;
+ var mapPosXAddPix = clickX + buffer;
+ var mapPosYAddPix = clickY + buffer;
+ var mapPosXRemovePix = clickX - buffer;
+ var mapPosYRemovePix = clickY - buffer;
+ var realWorld1 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+ var realWorld2 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld3 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld4 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+ for(var i=0; i<js_wfs_conf_id.length; i++){
+ var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
+ param = "service=wfs&request=getFeature&version=1.0.0&typename="+ wfs_config[js_wfs_conf_id[i]]['featuretype_name']+"&filter=";
+ var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>";
+ filter += "<Intersects><ogc:PropertyName>";
+ for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
+ if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
+ filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+ }
+ }
+ filter += "</ogc:PropertyName><gml:Polygon srsName='4326'><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ filter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ filter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></ogc:Filter>";
+ url += param;
+ mb_get_geom_(url, filter, i, wfs_config[js_wfs_conf_id[i]]['featuretype_name'], js_wfs_conf_id[i], db_wfs_conf_id[i]);
+ }
+ return true;
+}
+function mb_get_geom_(url, filter, index, typename, js_wfs_conf_id, db_wfs_conf_id) {
+
+ mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,{'url':url,'filter':filter,'typename':typename,'js_wfs_conf_id':js_wfs_conf_id, 'db_wfs_conf_id':db_wfs_conf_id},function(js_code,status){
+ if (js_code) {
+ eval(js_code);
+ }
+ if (typeof(geom) == "undefined") {
+ var geom = new GeometryArray();
+ }
+ checkIfAllAjaxCallsFinished_(geom);
+ });
+}
+
+function checkIfAllAjaxCallsFinished_ (geom) {
+ numberOfFinishedAjaxCalls++;
+ if (typeof(geom) == 'object'){
+ _geomArray.union(geom);
+ }
+ if (numberOfFinishedAjaxCalls == numberOfAjaxCalls_) {
+ numberOfFinishedAjaxCalls = 0;
+ if(_geomArray.count()>0)
+ showWFSBalloon(_geomArray);
+ }
+}
+
+function createListOfGeometries(){
+ if(_geomArray.count()>0){
+ var listOfGeom = "<table style='background-color:#EEEEEE;'>\n";
+ if (_geomArray.count() > 0) {
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<tr><td style='color:black;font-size:12px;'>edit all</td>\n";
+ listOfGeom += "<td><img title='edit all' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryArrayToDigitize(_geomArray);'></img>";
+ listOfGeom += "</td>\n</tr>\n";
+ listOfGeom += "<tr>\n<td> </td>\n</tr>\n";
+ }
+ for (var i = 0 ; i < _geomArray.count(); i ++) {
+ if (_geomArray.get(i).get(-1).isComplete()) {
+ listOfGeom += "\t<tr>\n\t\t<td style = 'color:blue;font-size:12px;cursor:pointer;'\n";
+ listOfGeom += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
+ listOfGeom += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
+ listOfGeom += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+ var geomName = getListTitle(_geomArray.get(i));
+ //if (_geomArray.get(i).geomType == geomType.polygon) {geomName += "(polygon)";}
+ //else if (_geomArray.get(i).geomType == geomType.line) {geomName += "(line)";}
+ //else if (_geomArray.get(i).geomType == geomType.point) {geomName += "(point)";}
+ listOfGeom += ">" + geomName +"</td>";
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<td><img title='edit geometry object' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryToDigitize("+i+");'></img></td>";
+ }
+ listOfGeom += "\t\t</tr>\n";
+ }
+ }
+ }
+ listOfGeom += "</table>\n";
+ return listOfGeom;
+ }
+ else{
+ geometryIndex = 0;
+ wfsConf = get_complete_wfs_conf();
+ var wfsConfIndex = _geomArray.get(0).wfs_conf;
+ var currentWfsConf = wfsConf[wfsConfIndex];
+
+ var resultHtml = "";
+ resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+ 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){
+ //console.log(currentWfsConf.element[i].element_name+"---"+currentWfsConf.element[i].f_respos);
+ resultHtml +="<tr><td>\n";
+ resultHtml += currentWfsConf.element[i].f_label;
+ resultHtml +="</td>\n";
+ resultHtml += "<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");
+ }
+ resultHtml += newLink;
+ }
+ else{
+ resultHtml += elementVal;
+ }
+ resultHtml += "</td></tr>\n";
+ }
+ }
+ }
+ resultHtml += "</table>\n";
+ return resultHtml;
+ }
+}
+
+function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
+ return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
+}
+
+function Numsort (a, b) {
+ return a - b;
+}
+
+function getListTitle (geom) {
+ wfsConfId = geom.wfs_conf;
+ wfsConf = window.frames["wfs_conf"].get_wfs_conf();
+ if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
+ var resultArray = [];
+ var resultName = "";
+ 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']);
+ }
+ resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
+ }
+ }
+ resultArray.sort(Numsort);
+ var resultName = resultArray.join(" ");
+ if (resultName == "") {
+ resultName = wfsConf[wfsConfId]['g_label'];
+ }
+ return resultName;
+ }
+ else {
+ return msgObj.digitizeDefaultGeometryName;
+ }
+}
More information about the Mapbender_commits
mailing list