openlayers_behavior_geofield.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. * Implementation of OpenLayers behavior.
  5. */
  6. /**
  7. * Map Form Values Behavior
  8. */
  9. class openlayers_behavior_geofield extends openlayers_behavior {
  10. /**
  11. * Provide initial values for options.
  12. */
  13. function options_init() {
  14. return array(
  15. 'feature_types' => array(),
  16. 'allow_edit' => 1,
  17. );
  18. }
  19. function options_form($defaults = array()) {
  20. $features = array(
  21. 'point' => t('Point'),
  22. 'path' => t('Path'),
  23. 'polygon' => t('Polygon'),
  24. );
  25. return array(
  26. 'feature_types' => array(
  27. '#title' => t('Available Features'),
  28. '#type' => 'checkboxes',
  29. '#options' => $features,
  30. '#description' => t('Select what features are available to draw.'),
  31. '#default_value' => isset($defaults['feature_types']) ? $defaults['feature_types'] : array(),
  32. ),
  33. 'allow_edit' => array(
  34. '#title' => t('Allow shape modification'),
  35. '#type' => 'checkbox',
  36. '#description' => t('Can you edit and delete shapes.'),
  37. '#default_value' => isset($defaults['allow_edit']) ? $defaults['allow_edit'] : 1,
  38. ),
  39. );
  40. }
  41. /**
  42. * Render.
  43. */
  44. function render(&$map) {
  45. $geopath = drupal_get_path('module', 'geofield');
  46. drupal_add_js($geopath . '/includes/behaviors/js/openlayers_behavior_geofield.js');
  47. return $this->options;
  48. }
  49. }