[Mapbender-commits] r3114 - branches/noframes/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Oct 3 10:21:04 EDT 2008
Author: nimix
Date: 2008-10-03 10:21:04 -0400 (Fri, 03 Oct 2008)
New Revision: 3114
Modified:
branches/noframes/http/javascripts/mod_coords_div.php
branches/noframes/http/javascripts/mod_measure.php
Log:
Modified: branches/noframes/http/javascripts/mod_coords_div.php
===================================================================
--- branches/noframes/http/javascripts/mod_coords_div.php 2008-10-03 14:02:24 UTC (rev 3113)
+++ branches/noframes/http/javascripts/mod_coords_div.php 2008-10-03 14:21:04 UTC (rev 3114)
@@ -28,8 +28,11 @@
var mod_showCoords_div_img_off = new Image(); mod_showCoords_div_img_off.src = "<?php echo $e_src; ?>";
var mod_showCoords_div_img_over = new Image(); mod_showCoords_div_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
var mod_showCoords_div_fix = "";
+var mod_showCoords_div_mapObj = null;
function init_mod_showCoords_div(ind){
+ mod_showCoords_div_mapObj = getMapObjByName(mod_showCoords_div_target );
+
mb_button[ind] = document.getElementById(mod_showCoords_div_elName);
mb_button[ind].img_over = mod_showCoords_div_img_over.src;
mb_button[ind].img_on = mod_showCoords_div_img_on.src;
@@ -41,40 +44,24 @@
mb_button[ind].stop = new Function ("mod_showCoords_div_disable()");
}
function mod_showCoords_div_run(){
- window.frames[mod_showCoords_div_target].document.onmousemove = mod_showCoords_div_display;
- window.frames[mod_showCoords_div_target].document.onclick = mod_showCoords_div_click;
+ mod_showCoords_div_mapObj.getDomElement().onmousemove = mod_showCoords_div_display;
+ mod_showCoords_div_mapObj.getDomElement().onclick = mod_showCoords_div_click;
}
function mod_showCoords_div_disable(){
- window.frames[mod_showCoords_div_target].document.onclick = null;
- window.frames[mod_showCoords_div_target].document.onmousemove = null;
+ mod_showCoords_div_mapObj.getDomElement().onclick = null;
+ mod_showCoords_div_mapObj.getDomElement().onmousemove = null;
if(document.getElementById("dependentDiv")){
writeTag("","dependentDiv","");
}
}
function mod_showCoords_div_click(e){
- if(ie){
- clickX = window.frames[mod_showCoords_div_target].event.clientX;
- clickY = window.frames[mod_showCoords_div_target].event.clientY;
-
- }
- else{
- clickX = e.pageX;
- clickY = e.pageY;
- }
+ mod_showCoords_div_mapObj.getMousePos(e);
var pos = makeClickPos2RealWorldPos(mod_showCoords_div_target, clickX, clickY);
mod_showCoords_div_fix = "Selection: " + pos[0] + " / " + pos[1];
mod_showCoord_write(pos[0],pos[1]);
}
function mod_showCoords_div_display(e){
- if(ie){
- clickX = window.frames[mod_showCoords_div_target].event.clientX;
- clickY = window.frames[mod_showCoords_div_target].event.clientY;
-
- }
- else{
- clickX = e.pageX;
- clickY = e.pageY;
- }
+ mod_showCoords_div_mapObj.getMousePos(e);
var pos = makeClickPos2RealWorldPos(mod_showCoords_div_target, clickX, clickY);
mod_showCoord_write(pos[0],pos[1]);
}
Modified: branches/noframes/http/javascripts/mod_measure.php
===================================================================
--- branches/noframes/http/javascripts/mod_measure.php 2008-10-03 14:02:24 UTC (rev 3113)
+++ branches/noframes/http/javascripts/mod_measure.php 2008-10-03 14:21:04 UTC (rev 3114)
@@ -34,6 +34,7 @@
var mod_measure_elName = "measure";
var mod_measure_frameName = "";
+var mod_measure_mapObj = null;
var mod_measure_epsg;
var mod_measure_width;
var mod_measure_height;
@@ -48,6 +49,29 @@
var mod_measure_img_over = new Image(); mod_measure_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
function init_mod_measure(ind){
+ mod_measure_mapObj = getMapObjByName(mod_measure_target);
+ //ensure we have the div elements in Mapframe
+ var map_el = mod_measure_mapObj.getDomElement()
+ if(!map_el.ownerDocument.getElementById(mod_measure_target+"_measure_sub")){
+ el = map_el.ownerDocument.createElement("div");
+ el.style.position = "absolute";
+ el.style.top = "0px";
+ el.style.left = "0px";
+ el.style.zIndex = "16";
+ el.style.fontSize = "10px";
+
+ el1 = el.cloneNode(false);
+ el2 = el.cloneNode(false);
+
+ el.id = mod_measure_target+"_measure_sub";
+ el1.id = mod_measure_target+"_measure_display";
+ el2.id = mod_measure_target+"_measuring";
+
+ map_el.appendChild(el);
+ map_el.appendChild(el1);
+ map_el.appendChild(el2);
+ }
+
mb_button[ind] = document.getElementById(mod_measure_elName);
mb_button[ind].img_over = mod_measure_img_over.src;
mb_button[ind].img_on = mod_measure_img_on.src;
@@ -57,54 +81,55 @@
mb_button[ind].fName = mod_measure_frameName;
mb_button[ind].go = new Function ("mod_measure_go()");
mb_button[ind].stop = new Function ("mod_measure_disable()");
- var ind = getMapObjIndexByName(mod_measure_target);
- mod_measure_width = mb_mapObj[ind].width;
- mod_measure_height = mb_mapObj[ind].height;
- mod_measure_epsg = mb_mapObj[ind].epsg;
+ mod_measure_width = mod_measure_mapObj.width;
+ mod_measure_height = mod_measure_mapObj.height;
+ mod_measure_epsg = mod_measure_mapObj.epsg;
mb_registerSubFunctions("drawDashedLine()");
- mb_registerPanSubElement("measuring");
+ mb_registerPanSubElement(mod_measure_target+"measuring");
}
function register_measureSubFunctions(stringFunction){
mod_measureSubFunctions[mod_measureSubFunctions.length] = stringFunction;
}
function mod_measure_go(){
- var el = window.frames[mod_measure_target].document;
+ var el = mod_measure_mapObj.getDomElement();
el.onmousedown = mod_measure_start;
el.onmousemove = mod_measure_run;
el.onmouseover = function () {
- el.body.style.cursor = 'crosshair';
+ el.style.cursor = 'crosshair';
}
el.onmouseout = function () {
- el.body.style.cursor = 'auto';
+ el.style.cursor = 'auto';
}
var measureSub = "";
for(var i=0; i<mod_measureSubFunctions.length; i++){
measureSub += eval(mod_measureSubFunctions[i]);
- }
- writeTag(mod_measure_target,"measure_sub",measureSub);
+ }
+
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_sub",measureSub);
}
function mod_measure_disable(){
- var el = window.frames[mod_measure_target].document;
+ var el = mod_measure_mapObj.getDomElement();
el.onmousedown = null;
el.onmousemove = null;
el.onmouseover = null;
el.onmouseout = null;
- writeTag(mod_measure_target,"measure_display","");
- writeTag(mod_measure_target,"measure_sub","");
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display","");
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_sub","");
}
function mod_measure_timeout(){
- var el = window.frames[mod_measure_target].document;
+ var el = mod_measure_mapObj.getDomElement();
el.onmousedown = null;
el.ondblclick = null;
el.onmousemove = null;
}
function mod_measure_disableTimeout(){
- var el = window.frames[mod_measure_target].document;
+ var el = mod_measure_mapObj.getDomElement();
el.onmousedown = mod_measure_start;
el.onmousemove = mod_measure_run;
}
function mod_measure_start(e){
- mb_getMousePos(e,mod_measure_target);
+ mod_measure_mapObj.getMousePos(e);
+
var realWorldPos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY);
if(mod_measure_epsg=="EPSG:4326"){
mod_measure_RX[mod_measure_RX.length] = realWorldPos[0];
@@ -142,12 +167,11 @@
}
function drawDashedLine(){
//check if epsg has changed
- var ind = getMapObjIndexByName(mod_measure_target);
- mod_measure_width = mb_mapObj[ind].width;
- mod_measure_height = mb_mapObj[ind].height;
- if(mod_measure_epsg != mb_mapObj[ind].epsg){
+ mod_measure_width = mod_measure_mapObj.width;
+ mod_measure_height = mod_measure_mapObj.height;
+ if(mod_measure_epsg != mod_measure_mapObj.epsg){
mod_measure_delete();
- mod_measure_epsg = mb_mapObj[ind].epsg;
+ mod_measure_epsg = mod_measure_mapObj.epsg;
}
var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mod_measure_width+"' height='0'></div>";
str_mPoints += "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='0' height='"+mod_measure_height+"'></div>";
@@ -170,7 +194,7 @@
str_mPoints += evaluateDashes(pos1[0],pos1[1],pos0[0],pos0[1],k);
}
}
- writeTag(mod_measure_target,"measuring",str_mPoints);
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measuring",str_mPoints);
}
function evaluateDashes(x1,y1,x2,y2,count){
var str_dashedLine = "";
@@ -195,7 +219,7 @@
return str_dashedLine;
}
function mod_measure_run(e){
- mb_getMousePos(e,mod_measure_target);
+ mod_measure_mapObj.getMousePos(e);
var pos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY);
var dist;
if(mod_measure_epsg=="EPSG:4326"){
@@ -213,11 +237,11 @@
}
if(isNaN(dist) == false && clickX > 0 && clickX < mod_measure_width && clickY > 0 && clickY < mod_measure_height){
var str_display = "<span style='font-family:"+mod_measure_font+";font-size:"+mod_measure_fontsize+";color:"+mod_measure_color2+";'>"+(Math.round(dist*100)/100)+" m</span>";
- writeTag(mod_measure_target,"measure_display",str_display);
- mb_arrangeElement(mod_measure_target,"measure_display",clickX +2, clickY - 10);
+ writeTag(mod_measure_mapObj.frameName, mod_measure_target+"_measure_display",str_display);
+ mb_arrangeElement(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display",clickX +2, clickY - 10);
}
else{
- writeTag(mod_measure_target,"measure_display","");
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display","");
}
}
function mod_measure_close(){
@@ -255,6 +279,6 @@
mod_measure_RY = new Array();
mod_measure_Dist = new Array();
mod_measure_TotalDist = new Array();
- writeTag(mod_measure_target,"measuring","");
- writeTag(mod_measure_target,"measure_display","");
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measuring","");
+ writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display","");
}
\ No newline at end of file
More information about the Mapbender_commits
mailing list