You are here

function locationmap_page in Location Map 7

Same name and namespace in other branches
  1. 8.2 locationmap.module \locationmap_page()
  2. 7.2 locationmap.module \locationmap_page()

Menu callback; generate a page with Google Maps.

1 string reference to 'locationmap_page'
locationmap_menu in ./locationmap.module
Implements hook_menu().

File

./locationmap.module, line 214

Code

function locationmap_page() {
  $locationmap_title = variable_get('locationmap_title', t('Our Location'));
  $locationmap_body = variable_get('locationmap_body');
  $locationmap_footer = variable_get('locationmap_footer');
  $path = drupal_get_path('module', 'locationmap');
  $gmap_key = variable_get('locationmap_key');
  drupal_add_js('http://maps.google.com/maps?file=api&hl=en&v=2&key=' . $gmap_key, array(
    'type' => 'external',
    'weight' => 5,
  ));
  drupal_add_js($path . '/locationmap.js', array(
    'type' => 'file',
    'weight' => 6,
    'scope' => 'footer',
  ));
  $locationmap_settings = array(
    'address' => variable_get('locationmap_address', 'Fiordland, New Zealand'),
    'info' => variable_get('locationmap_info', 'Fiordland, New Zealand'),
    'lat' => variable_get('locationmap_lat', '-46.0868686'),
    'lng' => variable_get('locationmap_lng', '166.6822074'),
    'zoom' => variable_get('locationmap_zoom', 10),
    'type' => variable_get('locationmap_type', 'G_NORMAL_MAP'),
    'admin' => user_access('administer locationmap'),
  );
  if (!$locationmap_settings['info']) {
    $locationmap_settings['info'] = $locationmap_settings['address'];
  }
  drupal_add_js(array(
    'locationmap' => $locationmap_settings,
  ), 'setting');
  $output = '<div id="locationmap_body">' . $locationmap_body . '</div>';
  $output .= theme('locationmap_map');
  $output .= '<div id="locationmap_footer">' . $locationmap_footer . '</div>';
  if (user_access('administer locationmap')) {

    // TODO: Remove drupal_render and update to D7 desired behaviour. See http://drupal.org/update/modules/6/7#unrendered
    $form = drupal_get_form('locationmap_in_place_edit_form');
    $output .= drupal_render($form);
  }
  drupal_set_title($locationmap_title);
  return $output;
}