You are here

function gmap_views_pre_render in GMap Module 7.2

Same name and namespace in other branches
  1. 6.2 gmap.module \gmap_views_pre_render()
  2. 6 gmap.module \gmap_views_pre_render()
  3. 7 gmap.module \gmap_views_pre_render()

Implements hook_views_pre_render().

Pre render function to load ajax-js file, which is only possible if ajax is enabled in the display. @todo move this to GmapViewsToolbox

File

./gmap.module, line 630
GMap -- Routines to use the Google Maps API in Drupal.

Code

function gmap_views_pre_render(&$view) {
  static $gmap_processed = FALSE;

  // Add js only for gmap style views with ajax and not already processed.
  if ($view->plugin_name != 'gmap' && $view->plugin_name != 'gmapextended' || !$view->use_ajax || $gmap_processed) {
    return;
  }

  // Mark the view as already processed.
  $gmap_processed = TRUE;

  // Add js, now we are certain ajax is enabled.
  drupal_add_js(drupal_get_path('module', 'gmap') . '/js/gmap_views_ajax.js', array(
    'group' => JS_DEFAULT,
  ));
}