You are here

function _openlayers_presets_ui_form_center_map in Openlayers 6

Create Centering Map

Create map for interactive default centering

Parameters

$defaults: Array of defults to use for the map of centering and zooming

Return value

Themed map array

1 call to _openlayers_presets_ui_form_center_map()
openlayers_presets_ui_presets_manage_add in modules/openlayers_presets_ui/includes/openlayers_presets_ui.ui.inc
Menu Callback for Add Preset

File

modules/openlayers_presets_ui/includes/openlayers_presets_ui.ui.inc, line 1085
This file holds the functions for the openlayers presets ui

Code

function _openlayers_presets_ui_form_center_map($defaults = array()) {

  // Set up our map to help set center lat, lon and zoom
  // This map will always be projected as 4326 and use just the basic layer so that
  // even if the user is using screwed up map settings, this map will still function.
  $centermap_def = array(
    'id' => 'openlayers-center-helpmap',
    'projection' => '4326',
    'default_layer' => 'openlayers_default_wms',
    'width' => '400px',
    'height' => '300px',
    'center' => array(
      'lat' => $defaults['center']['lat'] ? $defaults['center']['lat'] : 0,
      'lon' => $defaults['center']['lon'] ? $defaults['center']['lon'] : 0,
      'zoom' => $defaults['center']['zoom'] ? $defaults['center']['zoom'] : 2,
    ),
    'layers' => array(
      'openlayers_default_wms',
    ),
    'controls' => array(
      'LayerSwitcher' => TRUE,
      'Navigation' => TRUE,
      'PanZoomBar' => TRUE,
      'MousePosition' => TRUE,
    ),
    'options' => array(
      'displayProjection' => $defaults['projection'],
    ),
    'events' => array(
      'moveend' => array(
        'updateCenterFormValues',
      ),
      'zoomend' => array(
        'updateCenterFormValues',
      ),
    ),
  );

  // Pass variables etc. to javascript
  $pass_values = array(
    'openlayersForm' => array(
      'projectionLayers' => _openlayers_presets_ui_get_projections($layers),
    ),
  );
  drupal_add_js($pass_values, 'setting');

  // Render map
  return openlayers_render_map($centermap_def);
}