Ive been pulling my hair out all day trying to get my custom dynamic OL style plugins from a drupal 6 installation to work in a new Drupal 7 installation. I have managed to successfully port all my custom behaviors, but just cant get my style plugins to work in D7. (OL 7.x-2.0)

When I originally created the style plugins for D6 I referred to STYLE_PLUGINS.TXT which was supplied with the Openlayers module and was a great help, but I cannot find a D7 version of this file? Does it exist yet? If not, is there anyone that can quickly highlight the changes that need to be made to convert a style plugin from openlayers 6.x-2.0 to 7.x-2.0.

this is my custom module code.

function openlayers_custom_ctools_plugin_api($module, $api) {
  if ($module == "openlayers") {
    switch ($api) {
      case 'openlayers_layers':
        return array('version' => 1);
      case 'openlayers_styles':
        return array('version' => 1);
    }
  }
}
function openlayers_custom_ctools_plugin_directory($module, $plugin) {
  if ($module == 'openlayers' && $plugin == 'style_plugin') {
     return 'plugins/style_plugin';
  }
}

and in my "plugins/style_plugin" folder, I have this in a .inc file (with the called js file too which)

$plugin = array(
  'title' => t('Custom Style Plugin'),
  'description' => t(''),
  'style_plugin' => array(
    'class' => 'openlayers_custom_style_plugin',
    'parent' => 'openlayers_style_plugin',
  ),
);

class openlayers_custom_style_plugin extends openlayers_style_plugin {

function options_form($defaults = array()) {
    $form = array();
    $form['point_radius_min'] = array(
      '#type' => 'textfield',
      '#title' => t('Min radius'),
      '#description' => t('Minimum value for the point radius.'),
      '#default_value' => isset($defaults['point_radius_min']) ?
        $defaults['point_radius_min'] : 5,
    );
    $form['point_radius_max'] = array(
      '#type' => 'textfield',
      '#title' => t('Max radius'),
      '#description' => t('Maximum value for the point radius.'),
      '#default_value' => isset($defaults['point_radius_max']) ?
        $defaults['point_radius_min'] : 30,
    );
    return $form;
}
function render() {
    drupal_add_js(drupal_get_path('module', 'openlayers_custom') .
    '/plugins/style_plugin/openlayers_custom_style_plugin.js');
}
}


I'm not even seeing the options form at /admin/structure/openlayers/styles/add

Please, any help or direction would be appreciated.

thanks

Comments

sambonner’s picture

Bumping this, would love to get answer either way myself.

Thanks,
Sam

pol’s picture

Hi there,

Styles are not yet refactored properly, it's in the pipe though...

pol’s picture

Status: Active » Closed (duplicate)
core44’s picture

Thanks, but the link just returns me to this post?

I ended up rebuilding my style plugin as a behavior and it seems to be working ok for the moment.