You are here

function ip_geoloc_library_alter in IP Geolocation Views & Maps 7

Implements hook_library_alter().

Swaps in the region-bound extension of the Leaflet MarkerCluster library, if it exists.

File

./ip_geoloc.module, line 149
IPGV&M is a mapping engine for Views that contain locations of entities and/or visitors. Google Maps, Leaflet and OpenLayers2 maps are all supported. and available through this module. Using a number of optional sources IPGV&M also retrieves…

Code

function ip_geoloc_library_alter(&$libraries, $module) {
  if (isset($libraries['leaflet_markercluster']['js'][0]['data'])) {
    $js = $libraries['leaflet_markercluster']['js'][0]['data'];
    $last_slash = strrpos($js, '/');
    $js_new = drupal_substr($js, 0, $last_slash + 1) . IP_GEOLOC_LEAFLET_MARKERCLUSTER_REGIONBOUND_JS;

    //drupal_set_message(t('Current Leaflet MarkerCluster plugin: %js.<br/>Looking for %js_new', array('%js' => $js, '%js_new' => $js_new)));
    if (file_exists($js_new)) {
      $libraries['leaflet_markercluster']['js'][0]['data'] = $js_new;
    }
  }
}