Hi!
All the nodes without geo information are displaying a map. Shouldn't the map be hidden if there is no marker?
If this is "by design", is there a way to hack it?

Thanks!
Ricardo

Comments

sir.eduha’s picture

Hi! I add function to template.php in theme folder:


function phptemplate_simplest_gmap_formatter_default($element) {
  global $_simplest_gmap_defaults;
  // we need to get default settings for this specific field.
  $field = content_fields($element['#field_name'], $element['#type_name']);
  if (simplest_gmap_content_is_empty($element['#item'], $field)) {
    return NULL;
  }
  $default_elements = array_keys($_simplest_gmap_defaults);
  $defaults = array();
  foreach ($default_elements as $k) {
    $defaults[$k] = $field[$k];
  }

  $map_id = 'map_'. $element['#field_name'] .'_'. $element['#item']['#delta'] .'_'. user_password(15);

  _simplest_gmap_init();

  $settings = array($map_id => array(
    'map_id' => $map_id,
    'latitude' => $element['#item']['latitude'],
    'longitude' => $element['#item']['longitude'],
    'zoom' => $element['#item']['zoom'],
    'map_type' => $field['map_type'],
    'defaults' => $defaults,
    )
  );
  drupal_add_js(array("simplest_gmap" => $settings), 'setting');

  return '<div id="'. $map_id .'" style="width:'. $defaults['map_width'] .'px; height:'. $defaults['map_height'] .'px">'. $element['#item']['safe'] .'</div>';
}