? marker_theming_and_format.patch
? styles_hook.patch
? includes/openlayers.styles.inc
Index: openlayers.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/openlayers.module,v
retrieving revision 1.58
diff -u -p -r1.58 openlayers.module
--- openlayers.module	10 Jun 2009 01:43:28 -0000	1.58
+++ openlayers.module	14 Jun 2009 18:10:17 -0000
@@ -73,6 +73,12 @@ function openlayers_theme() {
       ),
       'file' => 'includes/openlayers.theme.inc',
     ),
+    'openlayers_vector_style' => array(
+      'arguments' => array(
+        'styles' => '',
+        'map' => '',
+      ),
+    ),
   );
 }
 
@@ -205,7 +211,9 @@ function openlayers_render_map($map = ar
   $map['layers'] = _openlayers_layers_process($map['layers'], $map);
   // Process behaviors
   $map['behaviors'] = _openlayers_behaviors_process($map['behaviors'], $map);
-  
+  // Process styles
+  $map['styles'] = _openlayers_styles_process($map['styles'], $map);
+    
   // Hook for one last alter
   // hook_openlayers_map_alter(&$map = array())
   drupal_alter('openlayers_map', $map);
@@ -281,6 +289,28 @@ function openlayers_behaviors_get_info($
 }
 
 /**
+ * Get Style Info
+ *
+ * Wrapper around style info hook
+ *
+ * @ingroup openlayers_api
+ * @param $reset
+ *   Boolean whether to reset cache or not
+ * @return
+ *   array of style info
+ */
+function openlayers_styles_get_info($reset = FALSE) {
+  static $info = array();
+  
+  // If empty or reset, get info
+  if (count($info) == 0 || $reset == TRUE) {
+    $info = module_invoke_all('openlayers_styles_info');
+  }
+
+  return $info;
+}
+
+/**
  * OpenLayers Form Wrapper
  *
  * Get the form array to customize OpenLayers Maps.  This is wrapper
@@ -615,6 +645,95 @@ function _openlayers_behaviors_process($
 }
 
 /**
+ * Implementation of hook_openlayers_styles_info
+ */
+function openlayers_openlayers_styles_info() {
+  // Define info array
+  $info['default'] = array(
+    'name' => t('Default Style'),
+    'description' => t('A basic style to get you started'),
+    'file' => drupal_get_path('module', 'openlayers') .'/includes/openlayers.styles.inc',
+    'callback' => 'openlayers_process_styles',
+  );
+  $info['select'] = array(
+    'name' => t('Default Select Style'),
+    'description' => t('Default style for selected geometries'),
+    'file' => drupal_get_path('module', 'openlayers') .'/includes/openlayers.styles.inc',
+    'callback' => 'openlayers_process_styles',
+  );  
+      
+  return $info;
+}
+
+/**
+ * Process Styles
+ *
+ * Get full data for any styles
+ *
+ * @param $styles
+ *   Array of styles to process
+ * @param $map
+ *   Map array
+ * @return
+ *   Array of processed styles
+ */
+function _openlayers_styles_process($styles,$map) {
+  // If styles aren't set, use module defaults
+  if (!$styles){
+    $styles = array();
+    $defaults = _openlayers_get_map_defaults();
+    $styles = $defaults['default_styles'];
+  }
+    
+  $processed = array();
+  
+  // Get style info array
+  $style_info = openlayers_styles_get_info();
+      
+  // Go through styles
+  foreach ($styles as $k => $style) {
+    // Check if array, if array, just pass on
+    if (is_array($style)) {
+      $processed[$k] = $style;
+    }
+    else {
+      // If not array, we want to include the file and call the function
+      if (($info = $style_info[$style]) && is_array($style_info[$style])) {
+        // Check if file exists
+        if (is_file('./'. $info['file'])) {          
+          require_once './'. $info['file'];
+          // Check for function
+          if (function_exists($info['callback'])) {
+            // Call function and give it the style name
+            $result = call_user_func_array($info['callback'], $style);
+            // Check for result
+            if (isset($result) && is_array($result)) {
+              $processed[$k] = $result['style_options'];
+            
+            }
+          }
+        }
+      }
+    }
+  }
+  
+  // Run through theme function  
+  $processed = theme_openlayers_vector_style($processed,$map);
+      
+  // Return processed
+  return $processed;
+}
+
+/**
+ * Theme function for vector style
+ */
+function theme_openlayers_vector_style($styles,$map) {
+  // pass through in order to make available for override
+  $output = $styles;
+  return $output;
+}
+
+/**
  * Create Map ID
  *
  * Create a unique ID for any maps that are not assigned an ID
@@ -654,6 +773,10 @@ function _openlayers_get_map_defaults() 
     'width' => 'auto',
     'default_layer' => 'openlayers_default_wms',
     'only_these_layers' => FALSE,
+    'default_styles' => array(
+      'default' => 'default',
+      'select' => 'select',
+      ),
     'height' => '300px',
     'center' => array(
       'lat' => '0',
Index: includes/openlayers.form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/includes/openlayers.form.inc,v
retrieving revision 1.23
diff -u -p -r1.23 openlayers.form.inc
--- includes/openlayers.form.inc	9 Jun 2009 07:19:17 -0000	1.23
+++ includes/openlayers.form.inc	14 Jun 2009 18:10:17 -0000
@@ -59,6 +59,7 @@ function _openlayers_map_form($form_stat
   // Initialize variables
   $form = array();
   $layers = openlayers_layers_get_info();
+  $styles = array_keys(openlayers_styles_get_info());
   $baselayers = array();
   $overlays = array();
   $defaults = $form_state;
@@ -274,6 +275,30 @@ function _openlayers_map_form($form_stat
     '#default_value' => $defaults['layers']['overlays'] ? $defaults['layers']['overlays'] : array(),
   );
   
+  // Styles
+  $form['styles'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Styles'),
+    '#description' => t('Set default styles'),  
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['styles']['default'] = array(
+    '#type' => 'select',
+    '#title' => 'Default',
+    '#description' => t('Default vector style'),  
+    '#options' => $styles,
+    '#default_value' => $defaults['styles']['default'],
+    );
+  $form['styles']['select'] = array(
+    '#type' => 'select',
+    '#title' => 'Selected',
+    '#description' => t('Style for Selected items (not yet implemented)'),  
+    '#options' => $styles,
+    '#default_value' => $defaults['styles']['select'],
+    );   
+    
   // Map options properties
   $form['options'] = array(
     '#type' => 'fieldset',
Index: js/openlayers.layers.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/js/openlayers.layers.js,v
retrieving revision 1.3
diff -u -p -r1.3 openlayers.layers.js
--- js/openlayers.layers.js	29 May 2009 00:43:36 -0000	1.3
+++ js/openlayers.layers.js	14 Jun 2009 18:10:17 -0000
@@ -41,36 +41,14 @@ OL.Layers.WMS = function(layerOptions, m
  * @return
  *  OpenLayers Vector layer object.
  */
-OL.Layers.Vector = function(layerOptions, mapid) {
-  // Get styles
-  var stylesAll = [];
-  // Process Options
-  if (OL.isSet(layerOptions.options)){
-    // Process Styles
-    if (OL.isSet(layerOptions.options.styles)) {
-      var stylesAdded = [];
-      for (var styleName in layerOptions.options.styles) {
-        stylesAdded[styleName] = new OpenLayers.Style(layerOptions.options.styles[styleName].options);
-      }
-      stylesAll = new OpenLayers.StyleMap(stylesAdded);
-    };
+OL.Layers.Vector = function(layerOptions, mapid) {    
+  // Get styles    
+  var stylesAdded = [];
+  for (var styleName in OL.mapDefs[mapid].styles) {    
+    stylesAdded = new OpenLayers.Style(OL.mapDefs[mapid].styles[styleName].style_options);
   }
-  
-  // @@TODO: not be hard-coded
-  var myStyles = new OpenLayers.StyleMap({
-    "default": new OpenLayers.Style({
-      pointRadius: 5, // sized according to type attribute
-      fillColor: "#ffcc66",
-      strokeColor: "#ff9933",
-      strokeWidth: 4,
-      fillOpacity:0.5
-    }),
-    "select": new OpenLayers.Style({
-      fillColor: "#66ccff",
-      strokeColor: "#3399ff"
-    })
-  });
-  
+  var myStyles = new OpenLayers.StyleMap(stylesAdded);
+      
   // Define layer object
   var returnVector = new OpenLayers.Layer.Vector(layerOptions.name, {styleMap: myStyles});
   
Index: modules/openlayers_views/views/openlayers_views_style_map.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/modules/openlayers_views/views/openlayers_views_style_map.inc,v
retrieving revision 1.12
diff -u -p -r1.12 openlayers_views_style_map.inc
--- modules/openlayers_views/views/openlayers_views_style_map.inc	12 Jun 2009 21:34:32 -0000	1.12
+++ modules/openlayers_views/views/openlayers_views_style_map.inc	14 Jun 2009 18:10:17 -0000
@@ -162,8 +162,27 @@ class openlayers_views_style_map extends
         '#dependency' => array('edit-style-options-data-source-value' => array('other_wkt')),
       );
     }
-    
-    // Behavior options
+
+    // Controls, Possible @TODO - Min, Max, Number of Zoom Levels
+    $form['settings'] = array(
+      '#type' => 'fieldset',
+      '#tree' => TRUE,
+      '#title' => t('Map Settings'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+      );
+    $form['settings']['controls'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Map Controls'),
+      '#options'=> array(
+        'LayerSwitcher' => 'Layer Switcher',
+        'Navigation' => 'Navigation',
+        'PanZoomBar' => 'Pan/Zoom Bar',
+        'MousePosition' => 'MousePosition',
+        ),
+      '#default_value' => isset($this->options['controls']) ? $this->options['controls'] : array('LayerSwitcher','Navigation','PanZoomBar','MousePosition'),
+      );  
+          
     if (module_exists('openlayers_behaviors')){
       $form['behaviors'] = array(
         '#type' => 'fieldset',
@@ -204,6 +223,20 @@ class openlayers_views_style_map extends
         '#collapsible' => TRUE,
         '#collapsed' => TRUE,
     );
+    $form['styles']['default'] = array(
+      '#type' => 'select',
+      '#title' => 'Default',
+      '#description' => t('Default vector style'),  
+      '#options' => $styles,
+      '#default_value' => $defaults['styles']['default'],
+      );
+    $form['styles']['select'] = array(
+      '#type' => 'select',
+      '#title' => 'Selected',
+      '#description' => t('Style for Selected items (not yet implemented)'),  
+      '#options' => $styles,
+      '#default_value' => $this->options['styles']['select'],
+      );
     $form['style']['snippet'] = array(
       '#type' => 'textarea',
       '#title' => t('Feature Styles function'),
@@ -346,8 +379,7 @@ class openlayers_views_style_map extends
   /**
    * Renders views (map)
    */
-  function render() {
-    
+  function render() {    
     // Check for live preview.
     if (isset($this->view->live_preview) && $this->view->live_preview) {
       return t('OpenLayers views are not compatible with live preview.');
@@ -401,6 +433,9 @@ class openlayers_views_style_map extends
         ),
       );
       
+      // Define Controls
+      $map['controls'] = $this->options['settings']['controls'];
+                
       // Set up behaviors
       $map['behaviors'] = array();
       
@@ -430,10 +465,10 @@ class openlayers_views_style_map extends
         }
       }
       // @@TODO Add settings from plugin options
-      
+            
       // Render map
       $map = openlayers_render_map($map);
-      
+            
       // Return map array
       $output .= theme($this->theme_functions(), $this->view, $this->options, $map, $title);
     }
