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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Mar 4 11:18:57 EST 2010


Author: astrid_emde
Date: 2010-03-04 11:18:55 -0500 (Thu, 04 Mar 2010)
New Revision: 5724

Added:
   trunk/mapbender/http/plugins/mb_zoomBar.js
Log:
new module zoom with slider

Added: trunk/mapbender/http/plugins/mb_zoomBar.js
===================================================================
--- trunk/mapbender/http/plugins/mb_zoomBar.js	                        (rev 0)
+++ trunk/mapbender/http/plugins/mb_zoomBar.js	2010-03-04 16:18:55 UTC (rev 5724)
@@ -0,0 +1,59 @@
+// Must define levels as array, like [250, 1000, 5000, 10000, 100000]
+if (typeof options.level !== "object" || !options.level.length) {
+	new Mapbender.Exception("No levels defined for zoomBar.");
+	return;
+}
+
+// Must define defaultLevel, index in array level
+if (typeof options.defaultLevel !== "number" 
+	|| options.defaultLevel < 0 
+	|| options.defaultLevel >= options.level.length) 
+{
+	options.defaultLevel = options.level.length - 1;
+}
+
+var $zoomBar = $(this);
+
+var ZoomBarApi = function () {
+	var that = this;
+
+	this.events = {
+		updated: new Mapbender.Event(),
+		slided: new Mapbender.Event()
+	};
+	
+	// repaint with current scale after the slider has been moved
+	this.events.updated.register(function (obj) {
+		options.$target.mapbender(function () {
+			this.repaintScale(null, null, obj.scale);
+		});
+	});
+	
+	// create slider
+	$zoomBar.slider({
+		orientation: "vertical",
+		min: 0,
+		max: options.level.length-1,
+		step: 1,
+		value: options.defaultLevel,
+		change: function (event, ui) {
+			that.events.updated.trigger({
+				scale: options.level[options.level.length-1-ui.value]
+			});
+		},
+		slide: function (event, ui) {
+			that.events.slided.trigger({
+				scale: options.level[options.level.length-1-ui.value]
+			});
+		}
+	});
+
+	// Set default scale on init
+	Mapbender.events.init.register(function () {
+		that.events.updated.trigger({
+			scale: options.level[options.level.length-1-options.defaultLevel]
+		});
+	});
+};
+
+$zoomBar.mapbender(new ZoomBarApi());



More information about the Mapbender_commits mailing list