i have two situations where setting the map size kills the map display.

In the first situation, I'm trying to resize a map a CCK map:

function s4s_maps_openlayers_map_preprocess_alter(&$map) {   
  
  if ($map['layers']['openlayers_cck_vector']) {
    #$map['width']=300;  // these break map
    #$map['height']=200; 

If I uncomment the width and height settings, then we get:

in node/add/contenttype or node/nid/edit: The CCK header field shows ("location") as does the field description, but not the field value, ie the map itself.

in node/nid: the map *does* show, but I have themed the node view via a tpl file and set the map in a div and set the width and height of the div in css. If I take that out, then the map disappears as in add and edit, and the map renders to the size of whatever I set the div to, not to what I set it in the array above.

So that's the first case. The second case is related:

I'm trying to set the map size, but not via hook but in the initial map array creation:

function s4s_blocks_block_user_location_map() {
  if (is_numeric(arg(1))) {      
    
    if ($user_loc=content_profile_load("user_location", arg(1))) {   
      
      $user_loc_field=$user_loc->field_user_location;
           
      $wkt_object = geo_wkb_get_data($user_loc_field['0']['wkb'], 'wkt');
      $wkt = $wkt_object['value'];   
      $preset = openlayers_get_preset("bc_terrain_new");
      $map = $preset['preset_data'];
      #$map['width']=300; // why does this break the map in alter hook AND even on a fresh map? 
      #$map['height']=200;
      $map['layers']['user_data'] = array (
        'id' => 'user_data',
        'name' => 'user_data',
        'type' => 'Vector',
        'features' => array (
          'loc1' => array (
            'wkt' => $wkt,
            'projection' => '4326',  // get this from the preset
            'attributes' => array(
              'username' => 'whatever',
              'uid' => 'whatever',
              'whateverelseyouwant' => 'cangohere',
            ),
          ),
        )
      );
    
      $map = openlayers_render_map($map);
      #print $map['themed'];

      $content = '<dl class="profile-category"><div class="user-map" id="openlayers-map-auto-id-0" class="openlayers-map openlayers-preset-bc_terrain_new"></div></dl>';
      
      $block['content'] = $content; 
      $block['subject'] = t('Location');
      return $block;

Now what's interesting here is that if I print the map with print $map['themed'] then it displays in the correct size (when the size setting is uncommented) but when I'm printing the map in the block, then it only displays if the size settings are commented out. And I did play a lot with surrounding divs and such. So instead of printing $map['themed'] I now print the themed code directly, but add the 'user-map' class to it so I can set the width and height in CSS as I did with the node-map above.

So there we have it. Most definitely the same issue, but I wanted to provide the two different contexts in which it was occurring to help with the troubleshooting. If this can't be replicated, let me know and I'll set about narrowing down the variables as I'm pretty sure it's not particular to my setup.

Cheers and gratitude,
Shiraz

Comments

zzolo’s picture

Category: bug » support

Hey Shiraz,

Thanks for the detailed report, but I think your problem is that you are not using valid CSS values for your height and width. "300" is not valid, you need some sort of unit, like "300px". Also, you should make them strings. Let me know how that works.

--
zzolo

Shiraz Dindar’s picture

Status: Active » Closed (fixed)

Zzolo, you are absolutely correct, I didn't realize the values needed to be CSS-formatted. I notice the documentation is now done up so hopefully I won't be pestering you with false issues anymore. Cheers.