[Mapbender-commits] r5276 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 5 11:54:37 EST 2010


Author: christoph
Date: 2010-01-05 11:54:37 -0500 (Tue, 05 Jan 2010)
New Revision: 5276

Added:
   trunk/mapbender/http/plugins/mb_navigation.js
Log:


Added: trunk/mapbender/http/plugins/mb_navigation.js
===================================================================
--- trunk/mapbender/http/plugins/mb_navigation.js	                        (rev 0)
+++ trunk/mapbender/http/plugins/mb_navigation.js	2010-01-05 16:54:37 UTC (rev 5276)
@@ -0,0 +1,107 @@
+/**
+ * Package: mb_navigation
+ *
+ * Description:
+ * Adds navigation arrows on top of the map
+ * 
+ * Files:
+ *  - http/plugins/mb_navigation.js
+ *
+ * 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('<appId>','mb_navigation',
+ * > 2,1,'','Navigation','div','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','',
+ * > 'div','../plugins/mb_navigation.js','','mapframe1','','');
+ *
+ * Help:
+ * http://www.mapbender.org/Navigation
+ *
+ * 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 iconDim = 20;
+var $this = $(this);
+
+Mapbender.events.init.register(function () {
+	options.$target.each(function () {
+		var $target = $(this);
+		var id = $target.attr("id");
+		var map = Mapbender.modules[id];
+
+		var positionArrow = function ($domElement, direction) {
+			var top, left;
+			switch (direction) {
+				case "n":
+					top = $target.css("top");
+					left = (
+						parseInt($target.css("left"), 10) + 
+						parseInt($target.css("width"), 10) / 2 - iconDim/2
+					) + "px";
+					break;
+				case "s":
+					top = (
+						parseInt($target.css("top"), 10) + 
+						parseInt($target.css("height"), 10) - iconDim
+					) + "px";
+					left = (
+						parseInt($target.css("left"), 10) + 
+						parseInt($target.css("width"), 10) / 2 - iconDim/2
+					) + "px";
+					break;
+				case "w":
+					top = (
+						parseInt($target.css("top"), 10) + 
+						parseInt($target.css("height"), 10) / 2 - iconDim/2
+					) + "px";
+					left = $target.css("left");
+					break;
+				case "e":
+					top = (
+						parseInt($target.css("top"), 10) + 
+						parseInt($target.css("height"), 10) / 2 - iconDim/2
+					) + "px";
+					left = (
+						parseInt($target.css("left"), 10) + 
+						parseInt($target.css("width"), 10) - iconDim
+					) + "px";
+					break;
+			}
+			$domElement.css({
+				top: top,
+				left: left,
+				position:"absolute",
+				zIndex: 1000
+			});
+		};
+		
+		var directionArray = ["n", "e", "s", "w"];
+		for (i in directionArray) {
+			(function () {
+				var dir = directionArray[i];
+				var $arrow = $("<span title='" + dir.toUpperCase() + "' " + 
+					"id='" + id + "_" + dir + "' class=" + 
+					"'ui-icon ui-corner-all ui-icon-triangle-1-" + dir + 
+					"'></span>").click(function () {
+					map.pan(dir);
+				}).mouseover(function () {
+					$(this).addClass("ui-state-default");
+				}).mouseout(function () {
+					$(this).removeClass("ui-state-default");
+				}).appendTo($this);
+				
+				map.events.dimensionsChanged.register(function () {
+					positionArrow($arrow, dir);
+				});
+			})();
+		}
+	});
+});



More information about the Mapbender_commits mailing list