[Mapbender-commits] r4370 - in trunk/mapbender: core http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jul 16 09:48:37 EDT 2009


Author: christoph
Date: 2009-07-16 09:48:37 -0400 (Thu, 16 Jul 2009)
New Revision: 4370

Added:
   trunk/mapbender/http/javascripts/mod_scalebar.js
Removed:
   trunk/mapbender/http/javascripts/mod_scalebar.php
Modified:
   trunk/mapbender/core/system.php
Log:
scalebar is no longer a .php file, but a .js

Modified: trunk/mapbender/core/system.php
===================================================================
--- trunk/mapbender/core/system.php	2009-07-16 13:46:58 UTC (rev 4369)
+++ trunk/mapbender/core/system.php	2009-07-16 13:48:37 UTC (rev 4370)
@@ -39,5 +39,5 @@
 	"zoomOut1,selArea1,pan1,copyright,dependentDiv,dragMapSize," .
 	"dynamicOverview,FeatureInfoRedirect,highlightPOI,navFrame,sandclock," .
 	"scaleBar,scaleSelect,setBBOX,setPOI2Scale,reload,overview,addWMS," . 
-	"repaint,changeEPSG,mousewheelZoom,doubleclickZoom,resizeMapsize"
+	"repaint,changeEPSG,mousewheelZoom,doubleclickZoom,resizeMapsize,scalebar"
 );

Added: trunk/mapbender/http/javascripts/mod_scalebar.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_scalebar.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_scalebar.js	2009-07-16 13:48:37 UTC (rev 4370)
@@ -0,0 +1,116 @@
+/**
+ * Package: scalebar
+ *
+ * Description:
+ * Displays scalebar in the map. The position currently is hard coded to the 
+ * lower left corner of the map frame. 
+ * 
+ * Files:
+ *  - http/javascripts/mod_scalebar.php
+ *
+ * SQL:
+ * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, 
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
+ * > 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 ('<gui_id>','scalebar',
+ * > 2,1,'scalebar','Scalebar','div','','',0,0,0,0,0,'','','div',
+ * > 'mod_scalebar.php','','mapframe1','','');
+ *
+ * Help:
+ * http://www.mapbender.org/Scalebar
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ * 
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
+var mod_scalebar_target = options.target;
+
+var mod_scalebar_left = 5;
+var mod_scalebar_bottom = 17;
+
+var mod_scalebar_color1 = "white";
+var mod_scalebar_color2 = "black";
+var mod_scalebar_font = "Arial, Helvetica, sans-serif";
+var mod_scalebar_fontsize = "9px";
+
+eventAfterMapRequest.register(function () {
+	mod_scalebar();
+});
+
+var mod_scalebar = function () {
+	var scale = Mapbender.modules[mod_scalebar_target].getScale();
+	var ind = getMapObjIndexByName(mod_scalebar_target);
+	if(scale < 10){
+		var unit = '10&nbsp;cm';
+		var factor = 10/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale >= 10 && scale < 100){
+		var unit = '1&nbsp;m';
+		var factor = 100/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale < 1000 && scale >= 100){
+		var unit = '10&nbsp;m';
+		var factor = 1000/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale < 10000 && scale >= 1000){
+		var unit = '100&nbsp;m';
+		var factor = 10000/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale < 100000 && scale >= 10000){
+		var unit = '1&nbsp;km';
+		var factor = 100000/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale < 1000000 && scale >= 100000){
+		var unit = '10&nbsp;km';
+		var factor = 1000000/scale;
+	var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale < 10000000 && scale >= 1000000){
+		var unit = '100&nbsp;km';
+		var factor = 10000000/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale < 100000000 && scale >= 10000000){
+		var unit = '1000&nbsp;km';
+		var factor = 100000000/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	if(scale >= 100000000){
+		var unit = '1000&nbsp;km';
+		var factor = 100000000/scale;
+		var img_width = Math.round(factor * mb_resolution);
+	}
+	var scalebarTag = "<img src='../img/scalebar_bw.gif' width='"+ img_width  +"' height='6'>&nbsp; ";
+	scalebarTag += "<div style='position:absolute;left:"+(img_width + 4)+"px;top:5px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
+	scalebarTag += "<div style='position:absolute;left:"+(img_width + 2)+"px;top:7px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
+	scalebarTag += "<div style='position:absolute;left:"+(img_width + 2)+"px;top:5px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
+	scalebarTag += "<div style='position:absolute;left:"+(img_width + 3)+"px;top:6px;color:"+mod_scalebar_color2+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'>"+ unit+"</div>";
+
+	var map_el = mb_mapObj[ind].getDomElement();
+	if(!map_el.ownerDocument.getElementById(mb_mapObj[ind].elementName+"_scalebar")){
+		//create Box Elements
+		el_top = map_el.ownerDocument.createElement("div");
+		el_top.style.position = "absolute";
+		el_top.style.top = "0px";
+		el_top.style.left = "0px";
+		el_top.style.width = "200px";
+		el_top.style.overflow = "hidden";
+		el_top.style.zIndex = "10";
+		el_top.id = mb_mapObj[ind].elementName+"_scalebar";
+		map_el.appendChild(el_top);
+	}
+	mb_arrangeElement("", mod_scalebar_target+"_scalebar", mod_scalebar_left, (mb_mapObj[ind].height - mod_scalebar_bottom));
+	writeTag(mb_mapObj[ind].frameName, mb_mapObj[ind].elementName+"_scalebar", scalebarTag);
+
+}
\ No newline at end of file

Deleted: trunk/mapbender/http/javascripts/mod_scalebar.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_scalebar.php	2009-07-16 13:46:58 UTC (rev 4369)
+++ trunk/mapbender/http/javascripts/mod_scalebar.php	2009-07-16 13:48:37 UTC (rev 4370)
@@ -1,105 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_scalebar.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");
-echo "var mod_scalebar_target = '".$e_target[0]."';";
-?>
-
-var mod_scalebar_left = 5;
-var mod_scalebar_bottom = 17;
-
-var mod_scalebar_color1 = "white";
-var mod_scalebar_color2 = "black";
-var mod_scalebar_font = "Arial, Helvetica, sans-serif";
-var mod_scalebar_fontsize = "9px";
-
-eventAfterMapRequest.register(function () {
-	mod_scalebar();
-});
-function mod_scalebar(){
-	var scale = mb_getScale(mod_scalebar_target);
-	var ind = getMapObjIndexByName(mod_scalebar_target);
-	if(scale < 10){
-		var unit = '10&nbsp;cm';
-		var factor = 10/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale >= 10 && scale < 100){
-		var unit = '1&nbsp;m';
-		var factor = 100/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 1000 && scale >= 100){
-		var unit = '10&nbsp;m';
-		var factor = 1000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 10000 && scale >= 1000){
-		var unit = '100&nbsp;m';
-		var factor = 10000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 100000 && scale >= 10000){
-		var unit = '1&nbsp;km';
-		var factor = 100000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 1000000 && scale >= 100000){
-		var unit = '10&nbsp;km';
-		var factor = 1000000/scale;
-	var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 10000000 && scale >= 1000000){
-		var unit = '100&nbsp;km';
-		var factor = 10000000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 100000000 && scale >= 10000000){
-		var unit = '1000&nbsp;km';
-		var factor = 100000000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale >= 100000000){
-		var unit = '1000&nbsp;km';
-		var factor = 100000000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	var scalebarTag = "<img src='../img/scalebar_bw.gif' width='"+ img_width  +"' height='6'>&nbsp; ";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 4)+"px;top:5px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 2)+"px;top:7px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 2)+"px;top:5px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 3)+"px;top:6px;color:"+mod_scalebar_color2+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'>"+ unit+"</div>";
-
-	var map_el = mb_mapObj[ind].getDomElement();
-	if(!map_el.ownerDocument.getElementById(mb_mapObj[ind].elementName+"_scalebar")){
-		//create Box Elements
-		el_top = map_el.ownerDocument.createElement("div");
-		el_top.style.position = "absolute";
-		el_top.style.top = "0px";
-		el_top.style.left = "0px";
-		el_top.style.width = "200px";
-		el_top.style.overflow = "hidden";
-		el_top.style.zIndex = "10";
-		el_top.id = mb_mapObj[ind].elementName+"_scalebar";
-		map_el.appendChild(el_top);
-	}
-	mb_arrangeElement("", mod_scalebar_target+"_scalebar", mod_scalebar_left, (mb_mapObj[ind].height - mod_scalebar_bottom));
-	writeTag(mb_mapObj[ind].frameName, mb_mapObj[ind].elementName+"_scalebar", scalebarTag);
-
-}
\ No newline at end of file



More information about the Mapbender_commits mailing list