This may be on the GMap side of things, but I can't get links within a GMap bubble to become Popups. They have the proper class, but are not being manipulated by Popups. I have ensured that the Popups weight is higher than the Gmap weight.

Any Ideas?

Comments

jlyon’s picture

The problem is that the gmap popup is being generated and the Popups API init code isn't being run. I'm looking into a work-around. I'll post back here if I figure anything out.

kvvnn’s picture

We eventually got it working by creating Views template overrides.

jlyon’s picture

Did you call popups_add_popups() in the views theme override files?

kvvnn’s picture

Yes. I attached our override for you.

We were doing a few crazy things, so there is a lot of specific code in there, but you can see how he implemented popups I think.

// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $header: An array of header labels keyed by field id.
 * - $fields: An array of CSS IDs to use for each field id.
 * - $class: A class or classes to apply to the table, based on settings.
 * - $row_classes: An array of classes to apply to each row, indexed by row
 *   number. This matches the index in $rows.
 * - $rows: An array of row items. Each row is an array of content.
 *   $rows are keyed by row number, fields within rows are keyed by field ID.
 * @ingroup views_templates
 */
// Defined Constants.
define("MAX_ADVICE_TEXT", 20);
define("MAX_ADVICE_PER_TAB", 5);
if(!preg_match("/admin\/build\/views\/nojs\/preview/", $_GET['q'])) {
  //Logger::debug_var("get", $_GET);
  //Logger::debug_log_message("i am in");

  $get = $_GET;
  //  $a = arg(0);
  //Logger::debug_var("a", $a);

  $view_name = 'Manage_Advice_View_2';
  $display = 'block_3';

  $arg = advice_build_view_arg($get);

  $view = views_get_view($view_name);
  $build = $view->execute_display($display, $args);
  $view_results = $view->result;
  
  foreach($view_results as $view_result) {
    $result = array();
    
    $result['nid'] = $view_result->nid; 
    $result['country'] = $view_result->location_node_data_field_advice_location_country; 
    $result['city'] = $view_result->location_node_data_field_advice_location_city; 
	 // the following line was removed, and the one after added, by kevin on mar 6 2010    
    //$advice = (strlen($view_result->node_data_field_advice_location_field_advice_value) > MAX_ADVICE_TEXT) ? substr($view_result->node_data_field_advice_location_field_advice_value, 0, MAX_ADVICE_TEXT) ."..." : $view_result->node_data_field_advice_location_field_advice_advice_value;
	 $advice = (strlen($view_result->node_data_field_advice_location_field_advice_value) > MAX_ADVICE_TEXT) ? substr($view_result->node_data_field_advice_location_field_advice_value, 0, MAX_ADVICE_TEXT) ."..." : $view_result->node_data_field_advice_location_field_advice_value;
    $link = "<div id = 'popup-div'  onClick = 'advicedClicked(this);'><span class = 'map-node-url' style = 'color:#027AC6; text-decoration:none; cursor: pointer;' nodeurl = '/node/". $result['nid'] ."/view'>". $advice . "</span></div>";
    
    $result['field_advice_advice_value'] = $link;
    $result['latitude'] = $view_result->location_node_data_field_advice_location_latitude;
    $result['longitude'] = $view_result->location_node_data_field_advice_location_longitude;
    $results[] = $result;
  }

  $data = array();

  foreach($results as $number => $info) {
    $key = "'" . $info['latitude'] . "," . $info['longitude'] ."'";
    $data[$key][] = $info;
    //unset($rows[$number]['latitude']);
    //unset($rows[$number]['longitude']);
  }

  $key = "ABQIAAAAaxo9CY3tIjrIcJoSfaR3vRRLHesgMGU3_kMtWu0g2pRkM7mEWBRH9fR0g9BABW-x2t3k_KGxGK60xA";
  $key = variable_get("googlemap_api_key", $key);
  drupal_set_html_head('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key='.$key.'" type="text/javascript"></script>');

  $zoom = 11;

  echo "<script language='JavaScript'>\n";
  echo "var js_array = new Array();\n";

  echo "var php_set = " . MAX_ADVICE_PER_TAB . "\n";
  echo "var zoom = $zoom; \n";


  $i = 0;
  foreach($data as $key => $info) {
    $html = "";
    $summary = "";
    
    $j = 1;
    foreach($info as $key => $value) {
      //$html .= "Advice " . $j . "<br/>";
      $html .= advice_create_html($value);
      $summary .= advice_create_summary_html($value);
      //      $mod = $j % 5;
      //$mod = $j % 3;
      $mod = $j % MAX_ADVICE_PER_TAB;
      $html .= "<hr/>";
      if(!$mod) {
	$html .= "#####";
      }
      $j++;
    }
    $html .= "#####";
    
    echo "js_array[$i] = new Array(3);\n";
    echo "js_array[$i][0] = ".$value['latitude'].";\n";
    echo "js_array[$i][1] = ".$value['longitude'].";\n";
    echo "js_array[$i][2] = '".str_replace("'", "\'", $html)."';\n";
    echo "js_array[$i][3] = '".str_replace("'", "\'", $summary)."';\n";
    $i++;
  }
  echo "</script>\n";

  popups_add_popups($rules);
  echo '<script type="text/javascript" src="/modules/popups/popups.js"></script>';

  echo '<script type="text/javascript" src="/sites/default/files/tabbed.js"></script>';
  echo '<script type="text/javascript" src="/sites/default/files/advice_gmap.js"></script>';
  print "<div id='gmap' style='width: 100%; height: 400px;'> </div>";
 }


function advice_create_html($value) {
  $html = ""; 


  if(!empty($value['country'])) {
    $html .= $value['city'] . ", " .$value['country']. "<br/>";
  }

  if(!empty($value['field_advice_advice_value'])) {
    $template = $value['field_advice_advice_value'];
    $template = str_replace(array("\r\n", "\n", "\r", "
"), array("<br/>", "<br/>", "<br/>", "<br/>"), $template);
    $html .= $template; 
  }
  return $html;
}


function advice_create_summary_html($value) {
  $html = "";


  if(!empty($value['country'])) {
    $html .= $value['city'] . ", " .$value['country']. "<br/>";
  }

  if(!empty($value['field_advice_advice_value'])) {
    //$html .= $value['field_advice_advice_value']. "-";
    $template = $value['field_advice_advice_value']. "-";
    $template = str_replace(array("\r\n", "\n", "\r", "
"), array("<br/>", "<br/>", "<br/>", "<br/>"), $template);
    $html .= $template; 
  }
}

function advice_build_view_arg($get) {
  return "";
}


jlyon’s picture

Great thanks!