You are here

public function IpGeoLocAPI::outputMapMultiVisitor in IP Geolocation Views & Maps 8

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

src/Services/IpGeoLocAPI.php, line 178

Class

IpGeoLocAPI
Class IpGeoAPI to interact with other modules.

Namespace

Drupal\ip_geoloc\Services

Code

public function outputMapMultiVisitor($locations, $div_id = 'ip-geoloc-map-multi-locations', $map_options = NULL, $map_style = NULL) {

  // drupal_add_js(IP_GEOLOC_GOOGLE_MAPS, ['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 = [
  //   '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;
}