You are here

function ip_geoloc_output_map_multi_visitor in IP Geolocation Views & Maps 8

Same name and namespace in other branches
  1. 7 ip_geoloc_api.inc \ip_geoloc_output_map_multi_visitor()

Outputs an HTML div placeholder into which will be injected a map.

The locations to be mapped are supplied as an array of lat,long coordinates.

Parameters

array $locations: array of location objects each containing lat/long pair and optionally address, visit count and last visit to appear when the marker is clicked

string $div_id: id of the div placeholder, can be anything as long as it's unique

string $map_options: as a JSON string, .e.g '{"mapTypeId":"roadmap", "zoom":15}'

string $map_style: CSS style applied to the div, e.g "height:250px; width:300px"

File

./ip_geoloc_api.inc, line 182
API functions of IP geolocation module

Code

function ip_geoloc_output_map_multi_visitor($locations, $div_id = 'ip-geoloc-map-multi-locations', $map_options = NULL, $map_style = NULL) {
  drupal_add_js(IP_GEOLOC_GOOGLE_MAPS, array(
    'type' => 'external',
    'group' => JS_LIBRARY,
  ));
  drupal_add_js(drupal_get_path('module', 'ip_geoloc') . '/js/ip_geoloc_gmap_multi_visitor.js');
  if (!isset($map_options)) {
    $map_options = IP_GEOLOC_RECENT_VISITORS_MAP_OPTIONS;
  }
  $settings = array(
    'ip_geoloc_locations' => $locations,
    'ip_geoloc_multi_location_map_div' => $div_id,
    'ip_geoloc_multi_location_map_options' => drupal_json_decode($map_options),
  );
  drupal_add_js($settings, 'setting');
  if (!isset($map_style)) {
    $map_style = IP_GEOLOC_MAP_DIV_DEFAULT_STYLE;
  }
  $map_placeholder = "<div id='{$div_id}'" . (empty($map_style) ? '' : " style='{$map_style}'") . '></div>';
  return $map_placeholder;
}