You are here

function hook_ip_geoloc_marker_locations_alter in IP Geolocation Views & Maps 7

Modify the array of locations coming from the View before they're mapped.

Parameters

array $marker_locations: An array of marker locations.

object $view: The view from which $marker_locations was generated.

1 function implements hook_ip_geoloc_marker_locations_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

ip_geoloc_generator_ip_geoloc_marker_locations_alter in ip_geoloc_generator/ip_geoloc_generator.module
Implements hook_ip_geoloc_marker_locations_alter().
1 invocation of hook_ip_geoloc_marker_locations_alter()
ip_geoloc_plugin_style_extract_locations in views/ip_geoloc_plugin_style.inc
Extract an array of locations from the supplied views_plugin_style.

File

./ip_geoloc.api.php, line 44
Hooks provided by "IP Geolocation Views & Maps" (ip_geoloc).

Code

function hook_ip_geoloc_marker_locations_alter(&$marker_locations, &$view) {

  // The $marker_location->marker_color has to be the name (without extension)
  // of one of the files in the ip_geoloc/markers directory, or alternative,
  // if configured at admin/config/system/ip_geoloc.
  // The code below changes the color of the first two markers returned by the
  // View to orange and yellow and then prepends an additional marker, not in
  // the View.
  // Because the marker is added at the front of the location array, the map can
  // be centered on it. Or you can choose one of the other centering options, as
  // per normal.
  //
  // Machine name of your view goes in the line below.
  if ($view->name == 'my_beautiful_view') {
    if (count($marker_locations) >= 2) {
      $marker_locations[0]->marker_color = 'orange';
      $marker_locations[1]->marker_color = 'yellow';
    }
    $observatory = new stdClass();
    $observatory->latitude = 51.4777;
    $observatory->longitude = -0.0015;
    $observatory->balloon_text = t('The zero-meridian passes through the courtyard of the <strong>Greenwich</strong> observatory.');
    $observatory->marker_color = 'white';
    array_unshift($marker_locations, $observatory);
  }
}