openlayers.default_openlayers_components.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @file
  4. * Provide default components.
  5. */
  6. /**
  7. * Implements hook_default_openlayers_components().
  8. */
  9. function openlayers_default_openlayers_components() {
  10. $export = array();
  11. $ol_component = new stdClass();
  12. $ol_component->disabled = TRUE; /* Edit this to true to make a default component disabled initially */
  13. $ol_component->api_version = 1;
  14. $ol_component->machine_name = 'openlayers_component_map_edit_form_values';
  15. $ol_component->name = 'Map edit form values';
  16. $ol_component->description = 'Provides values for the center, rotation and zoom in the map edit form.';
  17. $ol_component->factory_service = 'openlayers.Component:SetValues';
  18. $ol_component->options = array(
  19. 'latitude' => 'edit-options-view-center-lat',
  20. 'longitude' => 'edit-options-view-center-lon',
  21. 'rotation' => 'edit-options-view-rotation',
  22. 'zoom' => 'edit-options-view-zoom',
  23. 'extent' => 'edit-options-view-extent',
  24. );
  25. $export['openlayers_component_map_edit_form_values'] = $ol_component;
  26. // @todo: Transform this into a real component, without inlinejs.
  27. $ol_component = new stdClass();
  28. $ol_component->disabled = TRUE; /* Edit this to true to make a default component disabled initially */
  29. $ol_component->api_version = 1;
  30. $ol_component->machine_name = 'openlayers_component_map_edit_form_setcenter';
  31. $ol_component->name = 'Map center on mouse click';
  32. $ol_component->description = 'Upon clicking, center the map at the mouse position.';
  33. $ol_component->factory_service = 'openlayers.Component:InlineJS';
  34. $ol_component->options = array(
  35. 'javascript' => 'data.map.on(\'click\', function(evt){
  36. var pan = ol.animation.pan({
  37. duration: 2000,
  38. source: (data.map.getView().getCenter())
  39. });
  40. data.map.beforeRender(pan);
  41. data.map.getView().setCenter(evt.coordinate);
  42. });',
  43. );
  44. $export['openlayers_component_map_edit_form_setcenter'] = $ol_component;
  45. return $export;
  46. }