You are here

function ip_geoloc_openlayers_map_preprocess_alter in IP Geolocation Views & Maps 8

Same name and namespace in other branches
  1. 7 ip_geoloc.openlayers.inc \ip_geoloc_openlayers_map_preprocess_alter()

Implements hook_openlayers_map_preprocess_alter().

Add or alter map before main processing. Add styles, behaviors, layers.... Called from openlayers_build_map(). At this point center, zoom level etc. have already been initialised from the Map configuration page.

File

./ip_geoloc.openlayers.inc, line 22
ip_geoloc.openlayers.inc

Code

function ip_geoloc_openlayers_map_preprocess_alter(&$map) {

  // $map['center']['initial']['zoom'] = 5;
  // Introduce a number of layers that will be created below in function
  // ip_geoloc_openlayers_layers().
  $map['layers'][IP_GEOLOC_VISITOR_MARKER_LAYER] = IP_GEOLOC_VISITOR_MARKER_LAYER;
  $num_marker_layers = \Drupal::state()
    ->get('ip_geoloc_num_location_marker_layers', IP_GEOLOC_DEF_NUM_MARKER_LAYERS);
  for ($layer = 1; $layer <= $num_marker_layers; $layer++) {
    $map['layers'][IP_GEOLOC_MARKER_LAYER . $layer] = IP_GEOLOC_MARKER_LAYER . $layer;
    $map['layer_activated'][IP_GEOLOC_MARKER_LAYER . $layer] = IP_GEOLOC_MARKER_LAYER . $layer;

    // Markers may be switched on/off via a tickbox on the rendered map, if so
    // configured on page /admin/structure/openlayers/maps/<map_name>/edit,
    // vertical tab "Layers & Styles", bottom section "Overlay layers"
    // Programmatically, you'd do this like so:
    // $map['layer_switcher'][IP_GEOLOC_MARKER_LAYER . $layer] =
    // IP_GEOLOC_MARKER_LAYER . $layer;.
  }
}