? 710908_styles_fields.patch
? 721924_feature_limit.patch
? 814106_sortable_layers.patch
? 869834_kml_projection.patch
? includes/behaviors/.openlayers_behavior_drawfeatures.inc.swp
? includes/behaviors/js/.openlayers_behavior_drawfeatures.js.swp
? includes/behaviors/js/openlayers_behavior_query.css
? includes/behaviors/js/openlayers_behavior_query.js
? js/.openlayers.js.swp
? modules/openlayers_cck/.openlayers_cck.module.swp
? tests/plugins
Index: includes/behaviors/openlayers_behavior_drawfeatures.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/includes/behaviors/Attic/openlayers_behavior_drawfeatures.inc,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 openlayers_behavior_drawfeatures.inc
--- includes/behaviors/openlayers_behavior_drawfeatures.inc	7 May 2010 21:57:45 -0000	1.1.2.2
+++ includes/behaviors/openlayers_behavior_drawfeatures.inc	6 Aug 2010 16:50:40 -0000
@@ -17,6 +17,7 @@ class openlayers_behavior_drawfeatures e
     return array(
       'element_id' => '',
       'feature_types' => array(),
+      'feature_limit' => 0,
     );
   }
 
@@ -35,6 +36,14 @@ class openlayers_behavior_drawfeatures e
         '#description' => t('Select what features are available to draw.'),
         '#default_value' => isset($defaults['feature_types']) ? $defaults['feature_types'] : array(),
       ),
+      'feature_limit' => array(
+        '#title' => t('Number of features'),
+        '#type' => 'textfield',
+        '#description' => t('The number of features that are allowed to be 
+          drawn. Leave blank or at 0 for unlimited.'),
+        '#default_value' => isset($defaults['feature_limit']) ? 
+          $defaults['feature_limit'] : 0,
+      ),
       'element_id' => array(
         '#type' => 'textfield',
         '#default_value' => (isset($defaults['element_id'])) ?
Index: includes/behaviors/js/openlayers_behavior_drawfeatures.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/includes/behaviors/js/Attic/openlayers_behavior_drawfeatures.js,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 openlayers_behavior_drawfeatures.js
--- includes/behaviors/js/openlayers_behavior_drawfeatures.js	30 Jun 2010 14:23:30 -0000	1.1.2.10
+++ includes/behaviors/js/openlayers_behavior_drawfeatures.js	6 Aug 2010 16:50:40 -0000
@@ -6,50 +6,49 @@
  */
 
 /**
- * Update function for features
- *
- */
-function openlayers_behavior_drawfeatures_update(features) {
-  WktWriter = new OpenLayers.Format.WKT();
-  var features_copy = features.object.clone();
-  for(var i in features_copy.features) {
-    features_copy.features[i].geometry.transform(
-      features.object.map.projection,
-      new OpenLayers.Projection("EPSG:4326")
-    );
-  }
-  wkt_value = WktWriter.write(features_copy.features);
-  this.val(wkt_value);
-}
-
-/**
  * Behavior for Draw Features
  */
 Drupal.behaviors.openlayers_behavior_drawfeatures = function(context) {
+
+  function openlayers_behavior_drawfeatures_update(features) {
+    WktWriter = new OpenLayers.Format.WKT();
+    if (this.feature_limit < features.object.features.length) {
+      features.feature.layer.removeFeatures(features.object.features.shift());
+    }
+    var features_copy = features.object.clone();
+    for(var i in features_copy.features) {
+      features_copy.features[i].geometry.transform(
+        features.object.map.projection,
+        new OpenLayers.Projection("EPSG:4326")
+      );
+    }
+    this.element.val(WktWriter.write(features_copy.features));
+  }
+
   var data = $(context).data('openlayers');
   if (data && data.map.behaviors['openlayers_behavior_drawfeatures']) {
     var feature_types = data.map.behaviors['openlayers_behavior_drawfeatures'].feature_types;
       
-    // Add control
-    var openlayers_drawfeature_element = 
+    this.element = 
       $("#" + data.map.behaviors['openlayers_behavior_drawfeatures'].element_id);
+    this.feature_limit = 
+      data.map.behaviors['openlayers_behavior_drawfeatures'].feature_limit;
 
-    // Create options
-    var options = {
-      projection: new OpenLayers.Projection('EPSG:4326'),
-      drupalID: 'openlayers_drawfeatures_layer'
-    };
-    var styleMap = Drupal.openlayers.getStyleMap(data.map, options.drupalID);
-    var dataLayer = new OpenLayers.Layer.Vector(Drupal.t("Feature Layer"), options);
-    dataLayer.styleMap = styleMap;
+    var dataLayer = new OpenLayers.Layer.Vector(
+      Drupal.t("Feature Layer"),
+      {
+        projection: new OpenLayers.Projection('EPSG:4326'),
+        drupalID: 'openlayers_drawfeatures_layer'
+      }
+    )
+
+    dataLayer.styleMap = Drupal.openlayers.getStyleMap(data.map, 'openlayers_drawfeatures_layer');
     data.openlayers.addLayer(dataLayer);
 
-    if (openlayers_drawfeature_element.text() != '') {
+    if (this.element.text() != '') {
       var wktFormat = new OpenLayers.Format.WKT();
-      var wkt = openlayers_drawfeature_element.text();
-      var features = wktFormat.read(wkt);
+      var features = wktFormat.read(this.element.text());
       
-      // Check if features is an array
       if (features.constructor == Array) {
         for (var i in features) {
           features[i].geometry = features[i].geometry.transform(
@@ -70,49 +69,34 @@ Drupal.behaviors.openlayers_behavior_dra
 
     // registering events late, because adding data
     // would result in a reprojection loop
-    dataLayer.events.register('featureadded', openlayers_drawfeature_element,
+    dataLayer.events.register('featureadded', this,
       openlayers_behavior_drawfeatures_update);
-    dataLayer.events.register('featureremoved', openlayers_drawfeature_element,
+    dataLayer.events.register('featureremoved', this,
       openlayers_behavior_drawfeatures_update);
-    dataLayer.events.register('featuremodified', openlayers_drawfeature_element,
+    dataLayer.events.register('featuremodified', this,
       openlayers_behavior_drawfeatures_update);
     
     var control = new OpenLayers.Control.EditingToolbar(dataLayer);
     data.openlayers.addControl(control);
     control.activate();
 
-    var class_names = {
-      'point': 'OpenLayers.Handler.Point',
-      'path': 'OpenLayers.Handler.Path',
-      'polygon': 'OpenLayers.Handler.Polygon'
-    };
-
-    // Create index of valid handlers
-    var validHandler = {};
-    for(var j in feature_types) {
-       if (class_names[feature_types[j]]) {
-          validHandler[class_names[feature_types[j]]] = 1;
-       }
-    }
-
-    var defaultControl;
-    var c = [];
-    for(var i in control.controls) {
-      // Mark the navigation control as the default one
-      if (control.controls[i].CLASS_NAME == 'OpenLayers.Control.Navigation') {
-        c.push(control.controls[i]);
-        defaultControl = control.controls[i];
-      } else if (validHandler[control.controls[i].handler.CLASS_NAME]) {
-        c.push(control.controls[i]);
+    control.controls = $.map(control.controls,
+      function(control) {
+        return (control.CLASS_NAME == 'OpenLayers.Control.Navigation') ||
+          $.inArray(control.handler.CLASS_NAME,
+          $.map({
+              'point': 'OpenLayers.Handler.Point',
+              'path': 'OpenLayers.Handler.Path',
+              'polygon': 'OpenLayers.Handler.Polygon'
+            },
+            function(c) { return $.inArray(c, feature_types); })) ? control : null;
       }
-    }
-    control.controls = c;
-    if (defaultControl) {
-      control.activateControl(defaultControl);
-    }
+    );
+
+    control.activateControl(control.getControlsByClass('OpenLayers.Control.Navigation')[0]);
     control.redraw();
 
-    var mcontrol = new OpenLayers.Control.ModifyFeature(
+    control.addControls(new OpenLayers.Control.ModifyFeature(
       dataLayer, {
         displayClass: 'olControlModifyFeature',
         deleteCodes: [46, 68, 100],
@@ -125,7 +109,7 @@ Drupal.behaviors.openlayers_behavior_dra
           }
         }
       }
+      )
     );
-    control.addControls(mcontrol);
   }
 };
Index: modules/openlayers_cck/openlayers_cck.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/modules/openlayers_cck/openlayers_cck.module,v
retrieving revision 1.54.2.32
diff -u -p -r1.54.2.32 openlayers_cck.module
--- modules/openlayers_cck/openlayers_cck.module	8 Jul 2010 19:22:45 -0000	1.54.2.32
+++ modules/openlayers_cck/openlayers_cck.module	6 Aug 2010 16:50:40 -0000
@@ -439,7 +439,6 @@ function openlayers_cck_field_formatter_
  */
 function _openlayers_cck_render_element_map($field_name = '', 
   $field_label = '', $values = array(), $field = array()) {
-
   $field_id = 'edit-' . str_replace('_', '-', $field_name) . '-openlayers-wkt';
   
   // Get map to use for field
@@ -456,11 +455,22 @@ function _openlayers_cck_render_element_
 
   $map['id'] = OPENLAYERS_CCK_WIDGET_MAP_ID_PREFIX . '-' . $field_name;
 
+  if ($field['multiple'] == 0) {
+    $limit = 1;
+  }
+  elseif ($field['multiple'] > 1) {
+    $limit = $field['multiple'];
+  }
+  else {
+    $limit = 0;
+  }
+
   // Make sure that our display projection matches the database projection
   // TODO: rewrite
   $map['behaviors']['openlayers_behavior_drawfeatures'] = array(
     'element_id' => $field_id,
-    'feature_types' => $field['openlayers_cck_feature_types']
+    'feature_types' => $field['openlayers_cck_feature_types'],
+    'feature_limit' => $limit,
   );
 
   return openlayers_render_map($map);
