You are here

function gmap_gmap in GMap Module 6.2

Same name and namespace in other branches
  1. 5 gmap.module \gmap_gmap()
  2. 6 gmap.module \gmap_gmap()
  3. 7.2 gmap.module \gmap_gmap()
  4. 7 gmap.module \gmap_gmap()

Implementation of hook_gmap().

File

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

Code

function gmap_gmap($op, &$map) {
  switch ($op) {
    case 'macro':
      return array(
        'points' => array(
          'multiple' => TRUE,
        ),
        'markers' => array(
          'multiple' => TRUE,
        ),
        'feed' => array(
          'multiple' => TRUE,
        ),
        'style' => array(
          'multiple' => TRUE,
        ),
      );
    case 'pre_theme_map':
      $path = drupal_get_path('module', 'gmap') . '/js/';

      // Activate markers if needed.
      if (isset($map['behavior']['dynmarkers']) && $map['behavior']['dynmarkers'] || !empty($map['markers'])) {
        static $header_set = FALSE;
        if (!$header_set) {
          $header_set = TRUE;

          // If the user is using private download method, it's up to them to get the path set up.
          if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
            $markerpath = variable_get('gmap_private_markerfile', '');
            if (empty($markerpath) || !file_exists($markerpath)) {
              drupal_set_message(t('GMap marker file settings are not configured properly for Private download method, markers will not work!'), 'error');
            }
            else {
              drupal_add_js($markerpath, 'module', 'header', FALSE, TRUE, FALSE);
            }
          }
          else {
            $markerpath = file_create_path('js');
            if (!$markerpath || !file_exists("{$markerpath}/gmap_markers.js")) {
              gmap_regenerate_markers();
              $markerpath = file_create_path('js');
            }
            drupal_add_js("{$markerpath}/gmap_markers.js", 'module', 'header', FALSE, TRUE, FALSE);
          }
        }
        drupal_add_js($path . 'icon.js');
        drupal_add_js($path . 'marker.js');
        drupal_add_js($path . 'highlight.js');
        $mm = variable_get('gmap_mm_type', 'gmap');

        // If you really really want to override the marker manager, implement
        // this, take $mm by ref, and have fun. --Bdragon
        if (function_exists('_gmap_markermanager_override')) {
          _gmap_markermanager_override($mm);
        }
        drupal_add_js($path . $mm . '_marker.js');
      }
      if (isset($map['behavior']['locpick']) && $map['behavior']['locpick']) {
        drupal_add_js($path . 'locpick.js');
      }
      if (!empty($map['markers']) || !empty($map['lines'])) {
        drupal_add_js($path . 'markerloader_static.js');
      }
      if (!empty($map['shapes'])) {
        drupal_add_js($path . 'shapeloader_static.js');
        drupal_add_js($path . 'gmap_shapes.js');
      }
      if (isset($map['feed']) && is_array($map['feed'])) {
        drupal_add_js($path . 'markerloader_georss.js');
      }
      break;
    case 'macro_multiple':
      return array(
        'points',
        'markers',
        'feed',
        'circle',
        'rpolygon',
        'polygon',
        'line',
        'style',
      );
    case 'behaviors':
      return array(
        'locpick' => array(
          'title' => t('Location chooser'),
          'default' => FALSE,
          'help' => t('Used to activate location choosing using a gmap.'),
          'internal' => TRUE,
        ),
        'nodrag' => array(
          'title' => t('Disable dragging'),
          'default' => FALSE,
          'help' => t('Remove the ability for the user to drag the map. If dragging is disabled, keyboard shortcuts are implicitly disabled.'),
        ),
        'nokeyboard' => array(
          'title' => t('Disable keyboard'),
          'default' => TRUE,
          'help' => t('Disable the keyboard shortcuts.'),
        ),
        'nomousezoom' => array(
          'title' => t('Disable mousezoom'),
          'default' => FALSE,
          'help' => t('Disable using the scroll wheel to zoom the map.'),
        ),
        'nocontzoom' => array(
          'title' => t('Disable Continuous Zoom'),
          'default' => FALSE,
          'help' => t('Disable dynamically resizing images while waiting for tiles to load when zooming.'),
        ),
        'autozoom' => array(
          'title' => t('Use AutoZoom'),
          'default' => FALSE,
          'help' => t('Automatically zoom the map to fit all markers when markers are added.'),
        ),
        'dynmarkers' => array(
          'title' => t('Unconditionally enable marker interface'),
          'default' => FALSE,
          'help' => t('Load the marker loader system even if no markers to load are detected. Useful if you are injecting markers from somewhere else.'),
        ),
        'overview' => array(
          'title' => t('Enable Overview Map'),
          'default' => FALSE,
          'help' => t('Enable the "overview map" in the bottom right corner.'),
          'previewable' => TRUE,
        ),
        /*        'notype' => array(
                    'title' => t('Disable map type control'),
                    'default' => FALSE,
                    'help' => t('Removes the map type control from the upper right corner. Recommended for very narrow maps.'),
                    'previewable' => TRUE,
                  ), */
        'collapsehack' => array(
          'title' => t('Work around bugs when maps appear in collapsible fieldsets'),
          'default' => FALSE,
          'help' => t('Enabling this will work around some issues that can occur when maps appear inside collapsible fieldsets.'),
        ),
        // Note to myself, who keeps forgetting what a scale control actually IS.:
        // |------------  1mi ------------|
        'scale' => array(
          'title' => t('Add scale control to map.'),
          'default' => FALSE,
          'help' => t('Adds a scale control to the map in the default position.'),
          'previewable' => TRUE,
        ),
        'extramarkerevents' => array(
          'title' => t('Enable extra marker events.'),
          'default' => FALSE,
          'help' => t('Used for advanced javascript work, this will enable the <em>mouseovermarker</em>, <em>mouseoutmarker</em>, and <em>dblclickmarker</em> events.'),
          'internal' => TRUE,
        ),
        'clickableshapes' => array(
          'title' => t('Enable clickable shapes.'),
          'default' => FALSE,
          'help' => t('Used for advanced javascript work, this will enable the <em>clickshape</em> event.'),
          'internal' => TRUE,
        ),
        'googlebar' => array(
          'title' => t('Enable Google Bar'),
          'default' => FALSE,
          'help' => t('Enable the "Google Bar" at bottom of the map.'),
          'previewable' => TRUE,
        ),
        'highlight' => array(
          'title' => t('Highlight marker on rollover'),
          'default' => FALSE,
          'help' => t('Highlight marker by creating circle on mouse rollover event.'),
          'previewable' => TRUE,
        ),
      );
      break;
    case 'baselayers':
      $map['Google']['Map'] = array(
        'title' => t('Map: Standard street map.'),
        'default' => TRUE,
        'help' => t('The standard default street map. Internal name: G_NORMAL_MAP'),
      );
      $map['Google']['Satellite'] = array(
        'title' => t('Satellite: Standard satellite map.'),
        'default' => TRUE,
        'help' => t('Satellite view without street overlay. Internal name: G_SATELLITE_MAP'),
      );
      $map['Google']['Hybrid'] = array(
        'title' => t('Hybrid: Hybrid satellite map.'),
        'default' => TRUE,
        'help' => t('Satellite view with street overlay. Internal name: G_HYBRID_MAP'),
      );
      $map['Google']['Physical'] = array(
        'title' => t('Terrain: Physical feature map.'),
        'default' => FALSE,
        'help' => t('Map with physical data (terrain, vegetation.) Internal name: G_PHYSICAL_MAP'),
      );
      break;
  }
}