[OpenLayers-Commits] r2057 - in sandbox/camptocamp/advancedcontrol: examples lib lib/OpenLayers lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Thu Dec 14 10:42:25 EST 2006


Author: bertil
Date: 2006-12-14 10:42:24 -0500 (Thu, 14 Dec 2006)
New Revision: 2057

Added:
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Checkbox.js
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Choice.js
Modified:
   sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js
Log:
Checkbox and radio control

Modified: sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html
===================================================================
--- sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html	2006-12-14 14:28:31 UTC (rev 2056)
+++ sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html	2006-12-14 15:42:24 UTC (rev 2057)
@@ -7,7 +7,7 @@
             border: 1px solid black;
         }
         
-        #map2 {
+        #map1 {
             width: 512px;
             height: 512px;
             border: 1px solid black;
@@ -19,26 +19,36 @@
         function init(){
             var map = new OpenLayers.Map('map1');
             var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
-                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
+                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); 
 			// {div: $("containerControl")}
-			var container = new OpenLayers.Control.Container({div: $("containerControl")});
-			container.addControl(new OpenLayers.Control());
-			container.addControl(new OpenLayers.Control());
-			var button = new OpenLayers.Control.Button("bouton test");
-			container.addControl(button);            
+			var container = new OpenLayers.Control.Container();
+
+            var button = new OpenLayers.Control.Button("bouton test");
+            container.addControl(button);
             
-            var map2 = new OpenLayers.Map('map2');
-            var ol_wms2 = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
-                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
-            map2.addLayers([ol_wms2]);
-            map2.zoomToMaxExtent();
+            var choice1 = new OpenLayers.Control.Choice("radio");
+            container.addControl(choice1);
             
-            var mapcontr = new OpenLayers.Control.MouseDefaults();
-			mapcontr.setMap(map2);
-			map.addMouseListener(mapcontr);
+            var choice2 = new OpenLayers.Control.Choice("radio");
+            container.addControl(choice2);
+
+            var check = new OpenLayers.Control.Checkbox("check");
+            container.addControl(check);
+            
+            map.addControl(container);
+
+            button.addActionListener({actionPerformed: function(){alert("test")}});
+            button.addActionListener({actionPerformed: function(){alert("test2")}});
+            
+            choice1.addActionListener({actionPerformed: function(){alert("test")}});
+            choice1.addActionListener({actionPerformed: function(){alert("test2")}});
+            
+            choice2.addActionListener({actionPerformed: function(){alert("test")}});
+            choice2.addActionListener({actionPerformed: function(){alert("test2")}});
+            
+            check.addActionListener({actionPerformed: function(){console.log(arguments[0]);}});
+            check.addActionListener({actionPerformed: function(){console.log(arguments[0]);}});
 			
-			map.addControl(container);
-            
             map.addLayers([ol_wms]);
             map.zoomToMaxExtent();
         }

Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js	2006-12-14 14:28:31 UTC (rev 2056)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js	2006-12-14 15:42:24 UTC (rev 2057)
@@ -38,7 +38,6 @@
         if (this.div == null) {
             this.div = document.createElement("button");
             this.div.id = this.id;
-            this.div.style.position = "absolute";
             this.div.appendChild(document.createTextNode(this.name));
             this.div.className = this.controlName;
         }

Added: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Checkbox.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Checkbox.js	                        (rev 0)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Checkbox.js	2006-12-14 15:42:24 UTC (rev 2057)
@@ -0,0 +1,54 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Control.js
+ */
+OpenLayers.Control.Checkbox = OpenLayers.Class.create();
+OpenLayers.Control.Checkbox.prototype = OpenLayers.Class.inherit( OpenLayers.Control, {
+	
+	name: null,
+	
+	icon: null,
+	
+	actionListeners: null,
+	
+    /**
+     * @constructor
+     * 
+     * @param {Object} options
+     */
+    initialize: function(name, options) {
+        OpenLayers.Control.prototype.initialize.apply(this, options);
+        this.controlName = "olCheckbox";
+        this.name = name;
+    },
+    
+    /**
+     * @param {OpenLayers.Pixel} px
+     *
+     * @returns A reference to the DIV DOMElement containing the control
+     * @type DOMElement
+     */
+    draw: function (px) {
+        if (this.div == null) {
+            this.div = document.createElement("input");
+            this.div.type = "checkbox";
+            this.div.name = this.name;
+            this.div.id = this.id;
+            this.div.className = this.controlName;
+        }
+        if (px != null) {
+            this.position = px.clone();
+        }
+        this.moveTo(this.position);
+        
+        return this.div;
+    },
+    
+    CLASS_NAME: "OpenLayers.Control.Checkbox"
+
+});
\ No newline at end of file

Added: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Choice.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Choice.js	                        (rev 0)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Choice.js	2006-12-14 15:42:24 UTC (rev 2057)
@@ -0,0 +1,55 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Control.js
+ */
+OpenLayers.Control.Choice = OpenLayers.Class.create();
+OpenLayers.Control.Choice.prototype = OpenLayers.Class.inherit( OpenLayers.Control, {
+	
+	name: null,
+	
+	icon: null,
+	
+	actionListeners: null,
+	
+    /**
+     * @constructor
+     * 
+     * @param {Object} options
+     */
+    initialize: function(name, group, options) {
+        OpenLayers.Control.prototype.initialize.apply(this, options);
+        this.controlName = "olChoice";
+        this.name = name;
+    },
+
+    /**
+     * @param {OpenLayers.Pixel} px
+     *
+     * @returns A reference to the DIV DOMElement containing the control
+     * @type DOMElement
+     */
+    draw: function (px) {
+        if (this.div == null) {
+            this.div = document.createElement("input");
+            this.div.type = "radio";
+            this.div.id = this.id;
+            this.div.name = this.name;
+            this.div.appendChild(document.createTextNode(this.name));
+            this.div.className = this.controlName;
+        }
+        if (px != null) {
+            this.position = px.clone();
+        }
+        this.moveTo(this.position);
+        
+        return this.div;
+    },
+    
+    CLASS_NAME: "OpenLayers.Control.Choice"
+
+});
\ No newline at end of file

Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js	2006-12-14 14:28:31 UTC (rev 2056)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js	2006-12-14 15:42:24 UTC (rev 2057)
@@ -2,7 +2,6 @@
  * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
  * for the full text of the license. */
 
-
 /**
 * @class
 */
@@ -96,7 +95,7 @@
      * @param {OpenLayers.Control.ActionListener} actionListener
      */
     removeActionListener: function(actionListener) {
-    	penLayers.Event.observe(this.div, "click", actionListener.actionPerformed , false);
+    	OpenLayers.Event.dispose(this.div, "click", actionListener.actionPerformed , false);
     },
 
     /** @final @type String */

Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js	2006-12-14 14:28:31 UTC (rev 2056)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js	2006-12-14 15:42:24 UTC (rev 2057)
@@ -528,9 +528,10 @@
         control.setMap(this);
         var div = control.draw(px);
         // only elements without parents should be appended to the viewport 
-        if(!div.parentNode) { 
+        if(!div.parentNode) {
+        	div.style.position = "absolute";
             div.style.zIndex = this.Z_INDEX_BASE['Control'] + 
-            this.controls.length; 
+            this.controls.length;
             this.viewPortDiv.appendChild( div ); 
         } 
     },

Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js	2006-12-14 14:28:31 UTC (rev 2056)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js	2006-12-14 15:42:24 UTC (rev 2057)
@@ -93,6 +93,8 @@
         "OpenLayers/Control.js",
         "OpenLayers/Control/Container.js",
         "OpenLayers/Control/Button.js",
+        "OpenLayers/Control/Choice.js",
+        "OpenLayers/Control/Checkbox.js",
         "OpenLayers/Control/MouseListener.js",
         "OpenLayers/Control/MouseDefaults.js",
         "OpenLayers/Control/MouseToolbar.js",



More information about the Commits mailing list