Skip to content
Snippets Groups Projects
gmap.module 42.8 KiB
Newer Older
    '#default_value' => GMAP_LONGLAT,
    '#size' => 50,
webgeer's avatar
webgeer committed
    '#attributes' => array('onchange' => 'set_gmap_latlong(this.value);'),
  );
  $form['macroform']['width'] = array(
    '#type' => 'textfield',
    '#id' => 'gmap-width',
    '#title' => t('Map width'),
    '#default_value' => GMAP_WIDTH,
    '#size' => 25,
    '#attributes' => array('onchange' => 'set_gmap_dimension(this, \'width\');'),
  ); 
  $form['macroform']['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Map height'),
    '#id' => 'gmap-height',
    '#default_value' => GMAP_HEIGHT,
    '#size' => 25,
    '#attributes' => array('onchange' => 'set_gmap_dimension(this, \'height\');'),
  ); 
  $form['macroform']['alignment'] = array(
    '#type' => 'select', 
    '#id' => 'gmap-alignment',
    '#title' => t('Alignment'), 
    '#options' => drupal_map_assoc(array('None', 'Right', 'Left', 'Center')), 
//    '#default_value' => GMAP_ALIGNMENT,
    '#required' => FALSE,
    '#attributes' => array('onchange' => 'set_gmap_alignment(this.value);')
  );  
  $form['macroform']['clicktype'] = array(
    '#type' => 'select', 
    '#id' => 'gmap-clicktype',
    '#title' => t('What happens when you click on the map'), 
    '#options' => drupal_map_assoc(array('Points', 'Line1', 'Line2', 'Line3')), 
    '#required' => FALSE,
    '#default_value' => 'Points',
//    '#attributes' => array('onchange' => 'docontrol(this.value);')
  );    
  $form['macroform']['zoom'] = array(
    '#type' => 'select', 
    '#id' => 'gmap-zoom',
    '#title' => t('The current magnification of the map'),
    '#default_value' => GMAP_ZOOM,
    '#options' => drupal_map_assoc(range(0, 17)),
webgeer's avatar
webgeer committed
    '#attributes' => array('onchange' => 'setgmapZoom(this.value);'),
  );
  $form['macroform']['textarea'] = array(
    '#type' => 'textarea',
    '#id' => 'gmap-macrotext',
    '#title' => t('Macro text'),
  );
  return drupal_get_form('macroform', $form);
/**
 * Implementation of hook_views_style_plugins()
 */
function gmap_views_style_plugins() {
  return array(
    'gmap' => array(
      'name' => t('Gmap View'),
      'theme' => 'views_view_gmap',
      'needs_fields' => true,
      'validate' => 'views_ui_plugin_validate_list',
    )
  );
}

/**
 * Display the nodes of a view in a Google Map
 */
function theme_views_view_gmap($view, $nodes) {
  $fields = _views_get_fields();
  foreach ($nodes as $node) {
    $node_data = node_load(array("nid"=>$node->nid));
    $location = $node_data->location;
    $newmarker['label'] = '';
    foreach ($view->field as $field) {
      $newmarker['label'] .= "<p>" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node) . "</p>";
    }
    $newmarker['point']= $location['lat'] . ',' . $location['lon'];
    $newmarker['markername']='drupal_view';
    $thismap['markers'][]= $newmarker;
  }
  $output .= gmap_draw_map($thismap);
  return $output;
}