If you create a new node that has location information, the 'Location' fieldset appears in a box with scrollbars (see attached screenshot). With the Location module this just looks bad, but if you're also using the GMap module, it means the centre of the map is off-screen, making it very difficult to use.

The problem is that the "Longitude:" field's description text "If you want to supply your own ..." doesn't wrap, which forces the table to be so wide that it needs scrollbars.

If you look to the next field "Log Message:", you'll see its description text does wrap, so it looks fine.

I believe the "Longitude:" description wraps because of the "nowrap" in /modules/system/system.css :

tr.odd .form-item, tr.even .form-item {
  margin-top: 0;
  margin-bottom: 0;
  white-space: nowrap;
}

I found the description text is set in the following routine in location.inc, passed in using the "$description" parameter:

function location_latlon_form($description = '', $prefilled_values = array()) {
  $form = array();

  $usegmap = (function_exists('gmap_set_location') && variable_get('location_usegmap', 1));

  if ($usegmap) {
    $form['map'] = array();  //reserve spot at top of form for map
  }

  $form['latitude'] = array(
      '#type' => 'textfield',
      '#title' => t('Latitude'),
      '#default_value' => isset($prefilled_values['latitude']) ? $prefilled_values['latitude'] : '',
      '#size' => 64,
      '#maxlength' => 64
      );
  $form['longitude'] = array(
      '#type' => 'textfield',
      '#title' => t('Longitude'),
      '#default_value' => isset($prefilled_values['longitude']) ? $prefilled_values['longitude'] : '',
      '#size' => 64,
      '#maxlength' => 64,
      '#description' => $description,
      );

  if ($usegmap) {
    $map_macro = variable_get('gmap_user_map', '[gmap|id=usermap|center=0,30|zoom=16|width=100%|height=400px]');
    $form['map']['gmap']['#value'] = gmap_set_location($map_macro, $form, array('latitude'=>'latitude','longitude'=>'longitude'));
  }

  return $form;
}

I am using Drupal 5.2

So, I can see what's causing the problem, and there are several possible solutions including:
- does that css really need nowrap?
- quick hack, insert line breaks in the description text
- display the description text elsewhere, outside the area that has nowrap applied
- ... ?

Please can someone more familiar with Drupal help point me at what's the best way to fix this?

Thanks & regards, MrB

CommentFileSizeAuthor
#17 locationhack.jpg264.02 KBbwv
#5 patch_16.patch1.32 KBmrb
nowrap-screenshot.jpg108.2 KBmrb

Comments

ray007’s picture

Yes, you need to add a css line for form-items in the location input form to have white-space: normal;
See http://drupal.org/node/132445#comment-279834 and http://drupal.org/node/132445#comment-279966

mrb’s picture

Ray, thanks for the help. One more question - I see I need to update location.css, but when I looked at /node/add/page I couldn't see any mention of location.css. Is there another update I need to make to have the page consider location.css, or is that already taken care of somehow?

Regards, MrB

ray007’s picture

I think location.css currently doesn't get loaded anywhere.
I think there was an issue for that somewhere, but I've added the css to the theme for now ...

mrb’s picture

Status: Active » Closed (duplicate)

Thanks again, I'll follow up some more on the original 132445 you #mentioned.

mrb’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new1.32 KB

Issue 132445 mentions the solution to this problem, but doesn't provide a patch - so here's a patch.

The patch:
- adds the two lines from http://drupal.org/node/132445 to location.css, but comments out the existing entries in the css file as specified in http://drupal.org/node/124314
- edits function location_latlon_form in location.inc to add a call to drupal_add_css(drupal_get_path('module', 'location') .'/location.css');

Regards, MrB

jiangxijay’s picture

Subscribe

thekk’s picture

subscribing also

Foodster’s picture

Status: Needs review » Reviewed & tested by the community

I have tested the patch 16 with the latest dev, and it fixed the problem. please see the attachment for screenshot.

bdragon’s picture

http://drupal.org/node/136099 marked as duplicate.

mandclu’s picture

I still had an issue with the text not wrapping, at least in Firefox and Safari. Adding the following line to the CSS file fixed it for me:

form .locations .description { white-space: normal; }
scottrigby’s picture

#10 worked for me as well (after the other solutions did not) - using a modified Garland theme btw
thanks!

marcoBauli’s picture

uhm...yes, the location.css stylesheet does not seem to get loaded..

inserting the class above in the theme style.css does the job though

smitty’s picture

The form .locations .description { white-space: normal; } works fine for me too.

But also have a look at: http://drupal.org/node/213989

bdragon’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Marking as dupe of http://drupal.org/node/231419.

delineas’s picture

If your node add page doesn't load location.css add this to theme_location_form in location.theme:

drupal_add_css(drupal_get_path('module', 'location'). '/location.css', 'theme', 'screen');

Obviuosly n location.css add the line:

form .locations .description { white-space: normal; }

In Firefox works correctly

marcoBauli’s picture

#15 worked as expected, thanks for that

also added the following to location.css to work around and hide the second fieldset (one inside each other):

#node-form fieldset.locations fieldset.location {
border: none;
padding: 0;
margin: 0;
}

#node-form fieldset.locations fieldset.location legend {
display: none;
}

bwv’s picture

StatusFileSize
new264.02 KB

Thank you for the css fix, I'd been struggling with the location fieldset for some time.

I am developing a site using the location and gmap modules, and the only way I can get a registered user to be able to add a gmap marker is to grant permission to set latitude and longitude. Yet there is no need for these fields for my purposes, as the users can simply enter a postal code or manually place a marker on the map themselves.

Is there some means of hiding the latitude and longitude form fields? thanks

POSTSCRIPT: Figured this out by adding the following to my style.css:

#gmap-loc1-locpick_latitude0 {display: none;}
#gmap-loc1-locpick_longitude0 {display: none;}

By fiddling around with more style tags and hacking a little bit at the location.module and the location.inc files, I was able to display my location field as depicted in the attached image.