Skip to content
Snippets Groups Projects

styling for features, support for popups

Closed sano requested to merge issue/openlayers-3500706:3500706-enhancements-for-the into 7.x-3.x
1 file
+ 117
3
Compare changes
  • Side-by-side
  • Inline
@@ -5,12 +5,126 @@ namespace Drupal\openlayers\Plugin\Style\Cluster;
use Drupal\openlayers\Types\Style;
/**
* FIX - Insert short comment here.
* Enhanced cluster style with SVG icon support and circle fallbacks.
*
* @OpenlayersPlugin(
* id = "Cluster"
* )
*/
class Cluster extends Style {
// FIX: Provide options to let user customize the cluster style.
}
/**
* {@inheritdoc}
*/
public function optionsForm(array &$form, array &$form_state) {
// Icon configuration
$form['options']['single_icon'] = array(
'#type' => 'textfield',
'#title' => t('Single Camera Icon URL'),
'#default_value' => $this->getOption('single_icon', ''),
'#description' => t('URL for the single camera icon. SVG format recommended. Leave empty to use circle style.'),
);
$form['options']['single_icon_scale'] = array(
'#type' => 'textfield',
'#title' => t('Single Icon Scale'),
'#default_value' => $this->getOption('single_icon_scale', '0.25'),
'#description' => t('Scale factor for single camera icons (e.g., 0.5 for half size).'),
);
$form['options']['group_icon'] = array(
'#type' => 'textfield',
'#title' => t('Group Icon URL'),
'#default_value' => $this->getOption('group_icon', ''),
'#description' => t('URL for the group camera icon. SVG format recommended. Leave empty to use circle style.'),
);
$form['options']['group_icon_scale'] = array(
'#type' => 'textfield',
'#title' => t('Group Icon Scale'),
'#default_value' => $this->getOption('group_icon_scale', '0.75'),
'#description' => t('Scale factor for grouped camera icons.'),
);
$form['options']['single_radius'] = array(
'#type' => 'textfield',
'#title' => t('Single Feature Radius'),
'#default_value' => $this->getOption('single_radius', 8),
'#description' => t('Radius of the circle for single features.'),
// '#fieldset' => 'single_styles',
);
$form['options']['single_fill_color'] = array(
'#type' => 'textfield',
'#title' => t('Single Feature Fill Color'),
'#default_value' => $this->getOption('single_fill_color', '#3388ff'),
'#description' => t('Fill color for single feature circles (hex format).'),
);
$form['options']['single_stroke_color'] = array(
'#type' => 'textfield',
'#title' => t('Single Feature Stroke Color'),
'#default_value' => $this->getOption('single_stroke_color', '#ffffff'),
'#description' => t('Stroke (outline) color for single feature circles (hex format).'),
);
$form['options']['single_stroke_width'] = array(
'#type' => 'textfield',
'#title' => t('Single Feature Stroke Width'),
'#default_value' => $this->getOption('single_stroke_width', 2),
'#description' => t('Stroke (outline) width for single feature circles.'),
);
$form['options']['group_radius'] = array(
'#type' => 'textfield',
'#title' => t('Group Feature Radius'),
'#default_value' => $this->getOption('group_radius', 16),
'#description' => t('Radius of the circle for grouped features.'),
);
$form['options']['group_fill_color'] = array(
'#type' => 'textfield',
'#title' => t('Group Feature Fill Color'),
'#default_value' => $this->getOption('group_fill_color', '#c025bd'),
'#description' => t('Fill color for group circles (hex format).'),
);
$form['options']['group_stroke_color'] = array(
'#type' => 'textfield',
'#title' => t('Group Feature Stroke Color'),
'#default_value' => $this->getOption('group_stroke_color', '#ffffff'),
'#description' => t('Stroke (outline) color for group circles (hex format).'),
);
$form['options']['group_stroke_width'] = array(
'#type' => 'textfield',
'#title' => t('Group Feature Stroke Width'),
'#default_value' => $this->getOption('group_stroke_width', 2),
'#description' => t('Stroke (outline) width for group circles.'),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function optionsFormSubmit(array $form, array &$form_state) {
parent::optionsFormSubmit($form, $form_state);
// Ensure numeric values are properly typed
$numeric_fields = [
'single_icon_scale',
'group_icon_scale',
'single_radius',
'single_stroke_width',
'group_radius',
'group_stroke_width'
];
foreach ($numeric_fields as $field) {
if (isset($form_state['values']['options'][$field])) {
$form_state['values']['options'][$field] = (float) $form_state['values']['options'][$field];
}
}
}
}
\ No newline at end of file
Loading