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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Mar 28 10:10:17 EDT 2010


Author: christoph
Date: 2010-03-28 10:10:17 -0400 (Sun, 28 Mar 2010)
New Revision: 5848

Added:
   trunk/mapbender/http/plugins/mb_background.js
Log:
setbackground a la google maps

Added: trunk/mapbender/http/plugins/mb_background.js
===================================================================
--- trunk/mapbender/http/plugins/mb_background.js	                        (rev 0)
+++ trunk/mapbender/http/plugins/mb_background.js	2010-03-28 14:10:17 UTC (rev 5848)
@@ -0,0 +1,47 @@
+var $background = $(this);
+
+var BackgroundApi = function (o) {
+	var isVisibleBackgroundWms = function (wms) {
+		if (wms.gui_wms_visible === 2) {
+			return true;
+		}
+		return false;
+	};
+	
+	var isHiddenBackgroundWms = function (wms) {
+		if (wms.gui_wms_visible === 0) {
+			return true;
+		}
+		return false;
+	};
+	Mapbender.events.init.register(function () {
+		o.$target.each(function () {
+			var $map = $(this);
+			var $bgRadio = $("<div />").attr({
+				"id": this.id + "_" + o.id
+			}).addClass("container-background-wms");
+			var map = $map.mapbender();
+			$(map.wms).each(function () {
+				var wms = this;
+				var isVisible = isVisibleBackgroundWms(wms);
+				var isHidden = isHiddenBackgroundWms(wms);
+				if (!isHidden && !isVisible) {
+					return;
+				}
+				var html = "<span class='label-background-wms" + (isVisible ? " label-background-wms-active" : "") + "'>" + wms.wms_title + "</span>";
+				var $bgWms = $(html).data("wms", wms).click(function () {
+						// set as background WMS
+						wms.gui_wms_visible = 2;
+						$(this).addClass("label-background-wms-active").siblings().removeClass("label-background-wms-active").each(function () {
+							var wms = $(this).data("wms");
+							wms.gui_wms_visible = 0;
+						});
+						map.zoom(true, 0.999);
+					}).appendTo($bgRadio);
+			});
+			$bgRadio.appendTo($map);
+		});
+	});
+};
+
+$background.mapbender(new BackgroundApi(options));



More information about the Mapbender_commits mailing list